Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH] selftests/bpf: Fail unbound UDP on sockmap update
@ 2026-08-07 13:45 Ricardo B. Marlière (SUSE)
  2026-08-07 13:47 ` Ricardo B. Marlière (SUSE)
  2026-08-07 13:58 ` Greg KH
  0 siblings, 2 replies; 4+ messages in thread
From: Ricardo B. Marlière (SUSE) @ 2026-08-07 13:45 UTC (permalink / raw)
  To: Shuah Khan, sashal, gregkh, Andrii Nakryiko, Eduard Zingerman,
	Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau,
	Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa
  Cc: linux-kselftest, linux-kernel, stable, Michal Luczaj,
	Kuniyuki Iwashima, Jakub Sitnicki,
	Ricardo B. Marlière (SUSE)

From: Michal Luczaj <mhal@rbox.co>

[ Upstream commit 203b06932777b9ad5085319389dea566f5c2ca63 ]

sockmap now rejects unbound UDP sockets. Adjust test_maps. While at it,
check socket()'s return value.

This effectively reverts commit c39aa2159974 ("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>
---
Signed-off-by: Ricardo B. Marlière (SUSE) <ricardo@marliere.net>
---
Hi, backporting commit 66efd3368ae1 ("bpf, sockmap: Reject unhashed UDP
sockets on sockmap update") without this one broke the selftest in openSUSE
CI:

https://openqa.opensuse.org/tests/6147940/logfile?filename=test_maps.tap.txt
---
 tools/testing/selftests/bpf/test_maps.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c
index ccc5acd55ff9..d194b44ff8be 100644
--- a/tools/testing/selftests/bpf/test_maps.c
+++ b/tools/testing/selftests/bpf/test_maps.c
@@ -748,16 +748,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++) {

---
base-commit: 74b69060ba6e44e20c2e4dc1847eca21db6e4a7c
change-id: 20260807-selftests-bpf-sockmap-781db29c4f94

Best regards,
--  
Ricardo B. Marlière (SUSE) <ricardo@marliere.net>


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftests/bpf: Fail unbound UDP on sockmap update
  2026-08-07 13:45 [PATCH] selftests/bpf: Fail unbound UDP on sockmap update Ricardo B. Marlière (SUSE)
@ 2026-08-07 13:47 ` Ricardo B. Marlière (SUSE)
  2026-08-07 13:58 ` Greg KH
  1 sibling, 0 replies; 4+ messages in thread
From: Ricardo B. Marlière (SUSE) @ 2026-08-07 13:47 UTC (permalink / raw)
  To: Ricardo B. Marlière (SUSE), Shuah Khan, sashal, gregkh,
	Andrii Nakryiko, Eduard Zingerman, Alexei Starovoitov,
	Daniel Borkmann, Martin KaFai Lau, Kumar Kartikeya Dwivedi,
	Song Liu, Yonghong Song, Jiri Olsa
  Cc: linux-kselftest, linux-kernel, stable, Michal Luczaj,
	Kuniyuki Iwashima, Jakub Sitnicki

Ugh, sorry this is meant for 7.1.y

On Fri Aug 7, 2026 at 10:45 AM -03, Ricardo B. Marlière (SUSE) wrote:
> From: Michal Luczaj <mhal@rbox.co>
>
> [ Upstream commit 203b06932777b9ad5085319389dea566f5c2ca63 ]
>
> sockmap now rejects unbound UDP sockets. Adjust test_maps. While at it,
> check socket()'s return value.
>
> This effectively reverts commit c39aa2159974 ("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>
> ---
> Signed-off-by: Ricardo B. Marlière (SUSE) <ricardo@marliere.net>
> ---
> Hi, backporting commit 66efd3368ae1 ("bpf, sockmap: Reject unhashed UDP
> sockets on sockmap update") without this one broke the selftest in openSUSE
> CI:
>
> https://openqa.opensuse.org/tests/6147940/logfile?filename=test_maps.tap.txt
> ---
>  tools/testing/selftests/bpf/test_maps.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c
> index ccc5acd55ff9..d194b44ff8be 100644
> --- a/tools/testing/selftests/bpf/test_maps.c
> +++ b/tools/testing/selftests/bpf/test_maps.c
> @@ -748,16 +748,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++) {
>
> ---
> base-commit: 74b69060ba6e44e20c2e4dc1847eca21db6e4a7c
> change-id: 20260807-selftests-bpf-sockmap-781db29c4f94
>
> Best regards,
> --  
> Ricardo B. Marlière (SUSE) <ricardo@marliere.net>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftests/bpf: Fail unbound UDP on sockmap update
  2026-08-07 13:45 [PATCH] selftests/bpf: Fail unbound UDP on sockmap update Ricardo B. Marlière (SUSE)
  2026-08-07 13:47 ` Ricardo B. Marlière (SUSE)
@ 2026-08-07 13:58 ` Greg KH
  2026-08-07 14:24   ` Ricardo B. Marlière (SUSE)
  1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2026-08-07 13:58 UTC (permalink / raw)
  To: Ricardo B. Marlière (SUSE)
  Cc: Shuah Khan, sashal, Andrii Nakryiko, Eduard Zingerman,
	Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau,
	Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa,
	linux-kselftest, linux-kernel, stable, Michal Luczaj,
	Kuniyuki Iwashima, Jakub Sitnicki

On Fri, Aug 07, 2026 at 10:45:27AM -0300, Ricardo B. Marlière (SUSE) wrote:
> From: Michal Luczaj <mhal@rbox.co>
> 
> [ Upstream commit 203b06932777b9ad5085319389dea566f5c2ca63 ]
> 
> sockmap now rejects unbound UDP sockets. Adjust test_maps. While at it,
> check socket()'s return value.
> 
> This effectively reverts commit c39aa2159974 ("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>
> ---
> Signed-off-by: Ricardo B. Marlière (SUSE) <ricardo@marliere.net>

This goes above the --- line, right?

Please slow down, there's no rush here.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftests/bpf: Fail unbound UDP on sockmap update
  2026-08-07 13:58 ` Greg KH
@ 2026-08-07 14:24   ` Ricardo B. Marlière (SUSE)
  0 siblings, 0 replies; 4+ messages in thread
From: Ricardo B. Marlière (SUSE) @ 2026-08-07 14:24 UTC (permalink / raw)
  To: Greg KH, Ricardo B. Marlière (SUSE)
  Cc: Shuah Khan, sashal, Andrii Nakryiko, Eduard Zingerman,
	Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau,
	Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa,
	linux-kselftest, linux-kernel, stable, Michal Luczaj,
	Kuniyuki Iwashima, Jakub Sitnicki

On Fri Aug 7, 2026 at 10:58 AM -03, Greg KH wrote:
> On Fri, Aug 07, 2026 at 10:45:27AM -0300, Ricardo B. Marlière (SUSE) wrote:
>> From: Michal Luczaj <mhal@rbox.co>
>> 
>> [ Upstream commit 203b06932777b9ad5085319389dea566f5c2ca63 ]
>> 
>> sockmap now rejects unbound UDP sockets. Adjust test_maps. While at it,
>> check socket()'s return value.
>> 
>> This effectively reverts commit c39aa2159974 ("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>
>> ---
>> Signed-off-by: Ricardo B. Marlière (SUSE) <ricardo@marliere.net>
>
> This goes above the --- line, right?
>

Yeah I'm currently fighting with `b4` in the stable workflow :/

> Please slow down, there's no rush here.

This is actually a different commit, I sent before seeing your reply on the
other one. I'll double check before sending, thx

>
> thanks,
>
> greg k-h



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-07 14:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-07 13:45 [PATCH] selftests/bpf: Fail unbound UDP on sockmap update Ricardo B. Marlière (SUSE)
2026-08-07 13:47 ` Ricardo B. Marlière (SUSE)
2026-08-07 13:58 ` Greg KH
2026-08-07 14:24   ` Ricardo B. Marlière (SUSE)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox