Message ID | 1477768820-1295-2-git-send-email-iboukris@gmail.com |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
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.
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.
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');
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(-)