Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1511867 > unrolled thread
| Started by | Isaac Boukris <iboukris@gmail.com> |
|---|---|
| First post | 2016-10-29 21:30 +0200 |
| Last post | 2016-11-01 02:00 +0100 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] iproute2: ss: escape all null bytes in abstract unix domain socket Isaac Boukris <iboukris@gmail.com> - 2016-10-29 21:30 +0200
[PATCH] unix: escape all null bytes in abstract unix domain socket Isaac Boukris <iboukris@gmail.com> - 2016-10-29 21:30 +0200
Re: [PATCH] unix: escape all null bytes in abstract unix domain socket David Miller <davem@davemloft.net> - 2016-10-31 20:40 +0100
Re: [PATCH] unix: escape all null bytes in abstract unix domain socket Isaac Boukris <iboukris@gmail.com> - 2016-11-01 02:00 +0100
| From | Isaac Boukris <iboukris@gmail.com> |
|---|---|
| Date | 2016-10-29 21:30 +0200 |
| Subject | [PATCH] iproute2: ss: escape all null bytes in abstract unix domain socket |
| Message-ID | <sxHuh-2gb-3@gated-at.bofh.it> |
Abstract unix domain socket may embed null characters, these should be translated to '@' when printed by ss the same way the null prefix is currently being translated. Signed-off-by: Isaac Boukris <iboukris@gmail.com> --- misc/ss.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/misc/ss.c b/misc/ss.c index dd77b81..0e28998 100644 --- a/misc/ss.c +++ b/misc/ss.c @@ -2895,7 +2895,9 @@ static int unix_show_sock(const struct sockaddr_nl *addr, struct nlmsghdr *nlh, memcpy(name, RTA_DATA(tb[UNIX_DIAG_NAME]), len); name[len] = '\0'; if (name[0] == '\0') - name[0] = '@'; + for (int i = 0; i < len; i++) + if (name[i] == '\0') + name[i] = '@'; stat.name = &name[0]; memcpy(stat.local.data, &stat.name, sizeof(stat.name)); } -- 2.7.4
[toc] | [next] | [standalone]
| From | Isaac Boukris <iboukris@gmail.com> |
|---|---|
| Date | 2016-10-29 21:30 +0200 |
| Subject | [PATCH] unix: escape all null bytes in abstract unix domain socket |
| Message-ID | <sxHui-2gb-23@gated-at.bofh.it> |
| In reply to | #1511867 |
Abstract unix domain socket may embed null characters,
these should be translated to '@' when printed out to
proc the same way the null prefix is currently being
translated.
This helps for tools such as netstat, lsof and the proc
based implementation in ss to show all the significant
bytes of the name (instead of getting cut at the first
null occurrence).
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
---
net/unix/af_unix.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 145082e..9250b03 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -2805,14 +2805,19 @@ static int unix_seq_show(struct seq_file *seq, void *v)
i = 0;
len = u->addr->len - sizeof(short);
- if (!UNIX_ABSTRACT(s))
+ if (!UNIX_ABSTRACT(s)) {
len--;
- else {
+ for ( ; i < len; i++)
+ seq_putc(seq,
+ u->addr->name->sun_path[i]);
+ } else {
seq_putc(seq, '@');
i++;
+ for ( ; i < len; i++)
+ seq_putc(seq,
+ u->addr->name->sun_path[i] ?:
+ '@');
}
- for ( ; i < len; i++)
- seq_putc(seq, u->addr->name->sun_path[i]);
}
unix_state_unlock(s);
seq_putc(seq, '\n');
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2016-10-31 20:40 +0100 |
| Subject | Re: [PATCH] unix: escape all null bytes in abstract unix domain socket |
| Message-ID | <syqB4-6Fs-29@gated-at.bofh.it> |
| In reply to | #1511870 |
From: Isaac Boukris <iboukris@gmail.com>
Date: Sat, 29 Oct 2016 22:20:20 +0300
> Abstract unix domain socket may embed null characters,
> these should be translated to '@' when printed out to
> proc the same way the null prefix is currently being
> translated.
>
> This helps for tools such as netstat, lsof and the proc
> based implementation in ss to show all the significant
> bytes of the name (instead of getting cut at the first
> null occurrence).
>
> Signed-off-by: Isaac Boukris <iboukris@gmail.com>
...
> @@ -2805,14 +2805,19 @@ static int unix_seq_show(struct seq_file *seq, void *v)
>
> i = 0;
> len = u->addr->len - sizeof(short);
> - if (!UNIX_ABSTRACT(s))
> + if (!UNIX_ABSTRACT(s)) {
> len--;
> - else {
> + for ( ; i < len; i++)
> + seq_putc(seq,
> + u->addr->name->sun_path[i]);
> + } else {
> seq_putc(seq, '@');
> i++;
> + for ( ; i < len; i++)
> + seq_putc(seq,
> + u->addr->name->sun_path[i] ?:
> + '@');
> }
> - for ( ; i < len; i++)
> - seq_putc(seq, u->addr->name->sun_path[i]);
I think this patch is simpler if you just do the "@" translation
unconditionally, if it'll never trigger for the !UNIX_ABSTRACT case
that is perfectly fine.
[toc] | [prev] | [next] | [standalone]
| From | Isaac Boukris <iboukris@gmail.com> |
|---|---|
| Date | 2016-11-01 02:00 +0100 |
| Subject | Re: [PATCH] unix: escape all null bytes in abstract unix domain socket |
| Message-ID | <syvAJ-1pa-13@gated-at.bofh.it> |
| In reply to | #1512824 |
Hi David, thanks for looking at it.
On Mon, Oct 31, 2016 at 9:31 PM, David Miller <davem@davemloft.net> wrote:
> From: Isaac Boukris <iboukris@gmail.com>
> Date: Sat, 29 Oct 2016 22:20:20 +0300
>
>> Abstract unix domain socket may embed null characters,
>> these should be translated to '@' when printed out to
>> proc the same way the null prefix is currently being
>> translated.
>>
>> This helps for tools such as netstat, lsof and the proc
>> based implementation in ss to show all the significant
>> bytes of the name (instead of getting cut at the first
>> null occurrence).
>>
>> Signed-off-by: Isaac Boukris <iboukris@gmail.com>
> ...
>> @@ -2805,14 +2805,19 @@ static int unix_seq_show(struct seq_file *seq, void *v)
>>
>> i = 0;
>> len = u->addr->len - sizeof(short);
>> - if (!UNIX_ABSTRACT(s))
>> + if (!UNIX_ABSTRACT(s)) {
>> len--;
>> - else {
>> + for ( ; i < len; i++)
>> + seq_putc(seq,
>> + u->addr->name->sun_path[i]);
>> + } else {
>> seq_putc(seq, '@');
>> i++;
>> + for ( ; i < len; i++)
>> + seq_putc(seq,
>> + u->addr->name->sun_path[i] ?:
>> + '@');
>> }
>> - for ( ; i < len; i++)
>> - seq_putc(seq, u->addr->name->sun_path[i]);
>
> I think this patch is simpler if you just do the "@" translation
> unconditionally, if it'll never trigger for the !UNIX_ABSTRACT case
> that is perfectly fine.
I've sent an updated patch.
Logically now, the 'else' block just above could be removed, but it
isn't obvious from the code that 'sun_path[0] == 0' so I left it as
is.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web