]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
selftests/bpf: fix signedness bug in redir_partial()
authorFushuai Wang <wangfushuai@baidu.com>
Thu, 12 Jun 2025 08:42:08 +0000 (16:42 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Aug 2025 10:08:44 +0000 (12:08 +0200)
commit3ca8e73c58bb0a86b48422ba38edcad154a4f7b3
treec6580f29c40cccd4251635d3444de8620e2b4ff1
parent0e853c1464bcf61207f8b5c32d2ac5ee495e859d
selftests/bpf: fix signedness bug in redir_partial()

[ Upstream commit 6a4bd31f680a1d1cf06492fe6dc4f08da09769e6 ]

When xsend() returns -1 (error), the check 'n < sizeof(buf)' incorrectly
treats it as success due to unsigned promotion. Explicitly check for -1
first.

Fixes: a4b7193d8efd ("selftests/bpf: Add sockmap test for redirecting partial skb data")
Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
Link: https://lore.kernel.org/r/20250612084208.27722-1-wangfushuai@baidu.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/bpf/prog_tests/sockmap_listen.c