From: Luigi Leonardi <leonardi@redhat.com>
To: Stefano Garzarella <sgarzare@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
netdev@vger.kernel.org, Luigi Leonardi <leonardi@redhat.com>
Subject: [PATCH iproute2 v2 1/2] ss: move lport and rport in struct sockstat from int to long
Date: Mon, 17 Aug 2026 14:54:20 +0200 [thread overview]
Message-ID: <20260817-fix_vsock-v2-1-47e544221eae@redhat.com> (raw)
In-Reply-To: <20260817-fix_vsock-v2-0-47e544221eae@redhat.com>
Commit 012cb515 ("ss: change aafilter port from int to long (inode
support)") widened aafilter.port to long so that unix socket inode
numbers larger than INT_MAX can be used as port filter values, but left
sockstat.lport and sockstat.rport as int. This means large u32 values
(e.g. vsock ports or unix inodes > INT_MAX) are truncated on the
socket-stat side, making the comparison against aafilter.port always
fail.
Widen lport and rport to long and update the sscanf format specifiers
in proc_parse_inet_addr() and unix_show() accordingly.
Fixes: 012cb515 ("ss: change aafilter port from int to long (inode support)")
Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
---
misc/ss.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index 14e9f27a..ff1a88de 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -809,8 +809,8 @@ struct sockstat {
uint16_t raw_prot;
inet_prefix local;
inet_prefix remote;
- int lport;
- int rport;
+ long lport;
+ long rport;
int state;
int rq, wq;
unsigned int ino;
@@ -2490,23 +2490,23 @@ static int proc_parse_inet_addr(char *loc, char *rem, int family, struct
{
s->local.family = s->remote.family = family;
if (family == AF_INET) {
- sscanf(loc, "%x:%x", s->local.data, (unsigned *)&s->lport);
- sscanf(rem, "%x:%x", s->remote.data, (unsigned *)&s->rport);
+ sscanf(loc, "%x:%lx", s->local.data, (unsigned long *)&s->lport);
+ sscanf(rem, "%x:%lx", s->remote.data, (unsigned long *)&s->rport);
s->local.bytelen = s->remote.bytelen = 4;
return 0;
} else {
- sscanf(loc, "%08x%08x%08x%08x:%x",
+ sscanf(loc, "%08x%08x%08x%08x:%lx",
s->local.data,
s->local.data + 1,
s->local.data + 2,
s->local.data + 3,
- &s->lport);
- sscanf(rem, "%08x%08x%08x%08x:%x",
+ (unsigned long *)&s->lport);
+ sscanf(rem, "%08x%08x%08x%08x:%lx",
s->remote.data,
s->remote.data + 1,
s->remote.data + 2,
s->remote.data + 3,
- &s->rport);
+ (unsigned long *)&s->rport);
s->local.bytelen = s->remote.bytelen = 16;
return 0;
}
@@ -4638,8 +4638,8 @@ static int unix_show(struct filter *f)
if (!(u = calloc(1, sizeof(*u))))
break;
- if (sscanf(buf, "%x: %x %x %x %x %x %d %s",
- &u->rport, &u->rq, &u->wq, &flags, &u->type,
+ if (sscanf(buf, "%lx: %x %x %x %x %x %d %s",
+ (unsigned long *)&u->rport, &u->rq, &u->wq, &flags, &u->type,
&u->state, &u->ino, name) < 8)
name[0] = 0;
--
2.55.0
next prev parent reply other threads:[~2026-08-17 12:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 12:54 [PATCH iproute2 v2 0/2] ss: fix vsock port filtering Luigi Leonardi
2026-08-17 12:54 ` Luigi Leonardi [this message]
2026-08-17 12:54 ` [PATCH iproute2 v2 2/2] ss: fix vsock port filter Luigi Leonardi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260817-fix_vsock-v2-1-47e544221eae@redhat.com \
--to=leonardi@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox