mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
selftests/bpf: fix signedness bug in redir_partial()
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: a4b7193d8e ("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>
This commit is contained in:
committed by
Alexei Starovoitov
parent
3d71b8b9ab
commit
6a4bd31f68
@@ -924,6 +924,8 @@ static void redir_partial(int family, int sotype, int sock_map, int parser_map)
|
||||
goto close;
|
||||
|
||||
n = xsend(c1, buf, sizeof(buf), 0);
|
||||
if (n == -1)
|
||||
goto close;
|
||||
if (n < sizeof(buf))
|
||||
FAIL("incomplete write");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user