ss: fix vsock port filter

parse_hostcond() initializes aafilter.port to -1L (0xFFFFFFFFFFFFFFFF)
as a sentinel for "no port filter". When parsing a vsock port it called
get_u32() via a cast:

    get_u32((__u32 *)&a.port, port, 0)

get_u32() only writes 4 bytes, leaving the upper 32 bits of the 8-byte
long set from the -1 initialization. For example, for port 27354 this
produces 0xFFFFFFFF00006ADA, which never compares equal to sockstat.lport and
causes all vsock port filters to silently match nothing.

Fix by parsing into a temporary __u32 and assigning it to a.port, which
zero-extends the value correctly. When the user specifies '*' the if
block is skipped entirely and the -1 sentinel is preserved.

Fixes: 012cb515 ("ss: change aafilter port from int to long (inode support)")
Suggested-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
1 file changed