From: Stephen Hemminger <stephen@networkplumber.org>
To: Stefano Garzarella <sgarzare@redhat.com>
Cc: Luigi Leonardi <leonardi@redhat.com>,
stefanha@redhat.com, netdev@vger.kernel.org,
Mathieu Schroeter <mathieu@schroetersa.ch>,
David Ahern <dsahern@kernel.org>
Subject: Re: [PATCH iproute2] ss: fix vsock port filter
Date: Wed, 22 Apr 2026 09:21:00 -0700 [thread overview]
Message-ID: <20260422092100.46744a32@phoenix.local> (raw)
In-Reply-To: <CAGxU2F4C4JbqBEWehBhhOehGaXZJOWLkQ09hjaaSAh8-J5W50w@mail.gmail.com>
On Wed, 22 Apr 2026 10:03:49 +0200
Stefano Garzarella <sgarzare@redhat.com> wrote:
> On Wed, 22 Apr 2026 at 01:38, Stephen Hemminger <stephen@networkplumber.org> wrote:
> >
> > On Tue, 21 Apr 2026 14:35:12 +0200
> > Luigi Leonardi <leonardi@redhat.com> wrote:
> >
> > > parse_hostcond() uses get_u32() to parse the vsock port into the
> > > aafilter.port field, which is a long. On 64-bit systems, get_u32()
> > > only writes the lower 32 bits, leaving the upper 32 bits set from
> > > the -1 initialization. This causes the port comparison
> > > "a->port != s->rport" in run_ssfilter() to always fail, since the
> > > corrupted long value never matches the int rport.
> > >
> > > Fix by using get_long() instead, consistent with how AF_PACKET and
> > > AF_NETLINK handle the same field.
> > >
> > > Fixes: c759116a0b2b ("ss: add AF_VSOCK support")
> > > Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
> > > ---
> > > misc/ss.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/misc/ss.c b/misc/ss.c
> > > index 14e9f27a..6e3321ac 100644
> > > --- a/misc/ss.c
> > > +++ b/misc/ss.c
> > > @@ -2323,7 +2323,7 @@ void *parse_hostcond(char *addr, bool is_port)
> > > port = find_port(addr, is_port);
> > >
> > > if (port && strcmp(port, "*") &&
> > > - get_u32((__u32 *)&a.port, port, 0))
> > > + get_long(&a.port, port, 0))
> > > return NULL;
> >
> > If you use get_long() then the code could get negative values.
> > Actually have port in ss as signed value seems like a mistake in original design.
> >
> > The port in unix domain socket is inode number.
> > Originally it was int, but got changed to long back in 6.6
> >
> > The port in ss cache is int.
>
> Yeah, as I mentioned I think the issue was introduced by commit
> 012cb515 ("ss: change aafilter port from int to long (inode support)").
What about this which avoids the cast but keeps the same semantics.
diff --git a/misc/ss.c b/misc/ss.c
index 14e9f27a..e830e146 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -2317,14 +2317,16 @@ void *parse_hostcond(char *addr, bool is_port)
if (fam == AF_VSOCK) {
__u32 cid = ~(__u32)0;
+ __u32 vport = 0;
a.addr.family = AF_VSOCK;
port = find_port(addr, is_port);
-
- if (port && strcmp(port, "*") &&
- get_u32((__u32 *)&a.port, port, 0))
- return NULL;
+ if (port && strcmp(port, "*")) {
+ if (get_u32(&vport, port, 0))
+ return NULL;
+ }
+ a.port = vport;
if (!is_port && addr[0] && strcmp(addr, "*")) {
a.addr.bitlen = 32;
prev parent reply other threads:[~2026-04-22 16:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 12:35 [PATCH iproute2] ss: fix vsock port filter Luigi Leonardi
2026-04-21 14:01 ` Luigi Leonardi
2026-04-21 14:07 ` Stefano Garzarella
2026-04-21 16:03 ` Luigi Leonardi
2026-04-21 23:37 ` Stephen Hemminger
2026-04-22 8:03 ` Stefano Garzarella
2026-04-22 16:21 ` Stephen Hemminger [this message]
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=20260422092100.46744a32@phoenix.local \
--to=stephen@networkplumber.org \
--cc=dsahern@kernel.org \
--cc=leonardi@redhat.com \
--cc=mathieu@schroetersa.ch \
--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