* [xdp-hints] [PATCH bpf-next V1] selftests/bpf: fix unmap bug in prog_tests/xdp_metadata.c
@ 2023-02-01 18:12 Jesper Dangaard Brouer
2023-02-01 19:10 ` [xdp-hints] " Stanislav Fomichev
2023-02-01 23:50 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Jesper Dangaard Brouer @ 2023-02-01 18:12 UTC (permalink / raw)
To: bpf, Stanislav Fomichev
Cc: Jesper Dangaard Brouer, netdev, martin.lau, ast, daniel, andrii,
martin.lau, song, yhs, john.fastabend, dsahern, willemb, void,
kuba, xdp-hints
The function close_xsk() unmap via munmap() the wrong memory pointer.
The call xsk_umem__delete(xsk->umem) have already freed xsk->umem.
Thus the call to munmap(xsk->umem, UMEM_SIZE) will have unpredictable
behavior that can lead to Segmentation fault elsewhere, as man page
explain subsequent references to these pages will generate SIGSEGV.
Fixes: e2a46d54d7a1 ("selftests/bpf: Verify xdp_metadata xdp->af_xdp path")
Reported-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
.../selftests/bpf/prog_tests/xdp_metadata.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c
index e033d48288c0..241909d71c7e 100644
--- a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c
+++ b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c
@@ -121,7 +121,7 @@ static void close_xsk(struct xsk *xsk)
xsk_umem__delete(xsk->umem);
if (xsk->socket)
xsk_socket__delete(xsk->socket);
- munmap(xsk->umem, UMEM_SIZE);
+ munmap(xsk->umem_area, UMEM_SIZE);
}
static void ip_csum(struct iphdr *iph)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [xdp-hints] Re: [PATCH bpf-next V1] selftests/bpf: fix unmap bug in prog_tests/xdp_metadata.c
2023-02-01 18:12 [xdp-hints] [PATCH bpf-next V1] selftests/bpf: fix unmap bug in prog_tests/xdp_metadata.c Jesper Dangaard Brouer
@ 2023-02-01 19:10 ` Stanislav Fomichev
2023-02-01 23:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Stanislav Fomichev @ 2023-02-01 19:10 UTC (permalink / raw)
To: Jesper Dangaard Brouer
Cc: bpf, netdev, martin.lau, ast, daniel, andrii, martin.lau, song,
yhs, john.fastabend, dsahern, willemb, void, kuba, xdp-hints
On Wed, Feb 1, 2023 at 10:13 AM Jesper Dangaard Brouer
<brouer@redhat.com> wrote:
>
> The function close_xsk() unmap via munmap() the wrong memory pointer.
>
> The call xsk_umem__delete(xsk->umem) have already freed xsk->umem.
> Thus the call to munmap(xsk->umem, UMEM_SIZE) will have unpredictable
> behavior that can lead to Segmentation fault elsewhere, as man page
> explain subsequent references to these pages will generate SIGSEGV.
>
> Fixes: e2a46d54d7a1 ("selftests/bpf: Verify xdp_metadata xdp->af_xdp path")
> Reported-by: Martin KaFai Lau <martin.lau@kernel.org>
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Good catch, thank you!
Acked-by: Stanislav Fomichev <sdf@google.com>
> ---
> .../selftests/bpf/prog_tests/xdp_metadata.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c
> index e033d48288c0..241909d71c7e 100644
> --- a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c
> +++ b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c
> @@ -121,7 +121,7 @@ static void close_xsk(struct xsk *xsk)
> xsk_umem__delete(xsk->umem);
> if (xsk->socket)
> xsk_socket__delete(xsk->socket);
> - munmap(xsk->umem, UMEM_SIZE);
> + munmap(xsk->umem_area, UMEM_SIZE);
> }
>
> static void ip_csum(struct iphdr *iph)
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [xdp-hints] Re: [PATCH bpf-next V1] selftests/bpf: fix unmap bug in prog_tests/xdp_metadata.c
2023-02-01 18:12 [xdp-hints] [PATCH bpf-next V1] selftests/bpf: fix unmap bug in prog_tests/xdp_metadata.c Jesper Dangaard Brouer
2023-02-01 19:10 ` [xdp-hints] " Stanislav Fomichev
@ 2023-02-01 23:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-02-01 23:50 UTC (permalink / raw)
To: Jesper Dangaard Brouer
Cc: bpf, sdf, netdev, martin.lau, ast, daniel, andrii, martin.lau,
song, yhs, john.fastabend, dsahern, willemb, void, kuba,
xdp-hints
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:
On Wed, 01 Feb 2023 19:12:54 +0100 you wrote:
> The function close_xsk() unmap via munmap() the wrong memory pointer.
>
> The call xsk_umem__delete(xsk->umem) have already freed xsk->umem.
> Thus the call to munmap(xsk->umem, UMEM_SIZE) will have unpredictable
> behavior that can lead to Segmentation fault elsewhere, as man page
> explain subsequent references to these pages will generate SIGSEGV.
>
> [...]
Here is the summary with links:
- [bpf-next,V1] selftests/bpf: fix unmap bug in prog_tests/xdp_metadata.c
https://git.kernel.org/bpf/bpf-next/c/f2922f77a6a6
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-01 23:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-01 18:12 [xdp-hints] [PATCH bpf-next V1] selftests/bpf: fix unmap bug in prog_tests/xdp_metadata.c Jesper Dangaard Brouer
2023-02-01 19:10 ` [xdp-hints] " Stanislav Fomichev
2023-02-01 23:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox