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>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH iproute2 v2 0/2] ss: fix vsock port filtering
Date: Mon, 17 Aug 2026 14:54:19 +0200 [thread overview]
Message-ID: <20260817-fix_vsock-v2-0-47e544221eae@redhat.com> (raw)
Vsock port filtering is broken for ports in [1, 2^31−1] (i.e. any port
whose u32 representation has bit 31 clear, which includes all ordinarily
assigned vsock ports).
To reproduce:
ncat -l --vsock -p 27354
ss --vsock -l src :27354 # shows nothing
# Without the filter the socket is visible:
ss --vsock -l
Ports in [2^31, UINT_MAX−1] are not affected by accident.
aafilter.port was extended to 8 bytes to support unix socket inode
numbers larger than INT_MAX (see 012cb515). The vsock parsing path
initialises a.port to -1L and then calls get_u32() via a cast to write
the user-supplied port into it. get_u32() only writes 4 bytes, leaving
the upper 32 bits as 0xFFFFFFFF. For ports < 2^31 this produces a
mismatch with sockstat.lport.
For ports >= 2^31 the int-to-long sign extension also fills
the upper 32 bits with 0xFFFFFFFF, accidentally matching the corrupted
a.port and hiding the bug.
Commit 1 switches from int to long for sockstat.lport/rport
Commit 2 fixes a bug in the parsing of the filter port, that didn't
clear the upper bits.
Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
---
Changes in v2:
- Expanded lport and rport in sockstat from int to long [Stefano]
- Applied suggestion from Stephen for port filtering.
- Link to v1: https://lore.kernel.org/all/20260421-fix_vsock-v1-1-812c80a76c1a@redhat.com
---
Luigi Leonardi (2):
ss: move lport and rport in struct sockstat from int to long
ss: fix vsock port filter
misc/ss.c | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
---
base-commit: da2ccdf862cb1eab45de082cc71fcb4e5d712e78
change-id: 20260817-fix_vsock-f7b374d5cadd
Best regards,
--
Luigi Leonardi <leonardi@redhat.com>
next 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 Luigi Leonardi [this message]
2026-08-17 12:54 ` [PATCH iproute2 v2 1/2] ss: move lport and rport in struct sockstat from int to long Luigi Leonardi
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-0-47e544221eae@redhat.com \
--to=leonardi@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.com \
--cc=stephen@networkplumber.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.