mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
selftests/bpf: Fail unbound UDP on sockmap update
sockmap now rejects unbound UDP sockets. Adjust test_maps. While at it,
check socket()'s return value.
This effectively reverts commit c39aa21599 ("bpf, selftests: Fix
test_maps now that sockmap supports UDP").
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
Link: https://lore.kernel.org/bpf/20260707-sockmap-lookup-udp-leak-v4-4-f878346f27ab@rbox.co
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
This commit is contained in:
parent
30581eda4a
commit
203b069327
|
|
@ -759,16 +759,15 @@ static void test_sockmap(unsigned int tasks, void *data)
|
|||
goto out_sockmap;
|
||||
}
|
||||
|
||||
/* Test update with unsupported UDP socket */
|
||||
/* Test update with unsupported unbound UDP socket */
|
||||
udp = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
i = 0;
|
||||
err = bpf_map_update_elem(fd, &i, &udp, BPF_ANY);
|
||||
if (err) {
|
||||
printf("Failed socket update SOCK_DGRAM '%i:%i'\n",
|
||||
i, udp);
|
||||
CHECK(udp < 0, "socket(AF_INET, SOCK_DGRAM)", "errno:%d\n", errno);
|
||||
err = bpf_map_update_elem(fd, &(int){0}, &udp, BPF_ANY);
|
||||
close(udp);
|
||||
if (!err) {
|
||||
printf("Unexpectedly succeeded unbound UDP update '0:%i'\n", udp);
|
||||
goto out_sockmap;
|
||||
}
|
||||
close(udp);
|
||||
|
||||
/* Test update without programs */
|
||||
for (i = 0; i < 6; i++) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user