[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKH8qBt3XjsvhJfmkEpFxTOVPYNdLnrBOHZ9ekLM30hq6y4GEA@mail.gmail.com>
Date: Wed, 1 Feb 2023 11:10:29 -0800
From: Stanislav Fomichev <sdf@...gle.com>
To: Jesper Dangaard Brouer <brouer@...hat.com>
Cc: bpf@...r.kernel.org, netdev@...r.kernel.org, martin.lau@...nel.org,
ast@...nel.org, daniel@...earbox.net, andrii@...nel.org,
martin.lau@...ux.dev, song@...nel.org, yhs@...com,
john.fastabend@...il.com, dsahern@...il.com, willemb@...gle.com,
void@...ifault.com, kuba@...nel.org, xdp-hints@...-project.net
Subject: Re: [PATCH bpf-next V1] selftests/bpf: fix unmap bug in prog_tests/xdp_metadata.c
On Wed, Feb 1, 2023 at 10:13 AM Jesper Dangaard Brouer
<brouer@...hat.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@...nel.org>
> Signed-off-by: Jesper Dangaard Brouer <brouer@...hat.com>
Good catch, thank you!
Acked-by: Stanislav Fomichev <sdf@...gle.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)
>
>
Powered by blists - more mailing lists