bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Magnus Karlsson <magnus.karlsson@gmail.com>
Cc: "Magnus Karlsson" <magnus.karlsson@intel.com>,
	"Björn Töpel" <bjorn.topel@intel.com>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	Networking <netdev@vger.kernel.org>,
	"Jonathan Lemon" <jonathan.lemon@gmail.com>,
	bpf <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf 1/2] libbpf: fix null dereference in xsk_socket__delete
Date: Tue, 3 Nov 2020 11:02:15 -0800	[thread overview]
Message-ID: <CAEf4BzYfYpMqtzDnmZ+LK5tkYbbH95F5aOAvjVVP2Vzp9eFrMw@mail.gmail.com> (raw)
In-Reply-To: <1604396490-12129-2-git-send-email-magnus.karlsson@gmail.com>

On Tue, Nov 3, 2020 at 1:41 AM Magnus Karlsson
<magnus.karlsson@gmail.com> wrote:
>
> From: Magnus Karlsson <magnus.karlsson@intel.com>
>
> Fix a possible null pointer dereference in xsk_socket__delete that
> will occur if a null pointer is fed into the function.
>
> Fixes: 2f6324a3937f ("libbpf: Support shared umems between queues and devices")
> Reported-by: Andrii Nakryiko <andrii.nakryiko@gmail.com>
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> ---

Acked-by: Andrii Nakryiko <andrii@kernel.org>

>  tools/lib/bpf/xsk.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
> index e3c98c0..504b7a8 100644
> --- a/tools/lib/bpf/xsk.c
> +++ b/tools/lib/bpf/xsk.c
> @@ -891,13 +891,14 @@ int xsk_umem__delete(struct xsk_umem *umem)
>  void xsk_socket__delete(struct xsk_socket *xsk)
>  {
>         size_t desc_sz = sizeof(struct xdp_desc);
> -       struct xsk_ctx *ctx = xsk->ctx;
>         struct xdp_mmap_offsets off;
> +       struct xsk_ctx *ctx;
>         int err;
>
>         if (!xsk)
>                 return;
>
> +       ctx = xsk->ctx;
>         if (ctx->prog_fd != -1) {
>                 xsk_delete_bpf_maps(xsk);
>                 close(ctx->prog_fd);
> --
> 2.7.4
>

  reply	other threads:[~2020-11-03 19:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03  9:41 [PATCH bpf 0/2] libbpf: fix two bugs in xsk_socket__delete Magnus Karlsson
2020-11-03  9:41 ` [PATCH bpf 1/2] libbpf: fix null dereference " Magnus Karlsson
2020-11-03 19:02   ` Andrii Nakryiko [this message]
2020-11-03  9:41 ` [PATCH bpf 2/2] libbpf: fix possible use after free " Magnus Karlsson
2020-11-03 19:05   ` Andrii Nakryiko
2020-11-04  8:26     ` Magnus Karlsson
2020-11-04 19:42       ` Andrii Nakryiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAEf4BzYfYpMqtzDnmZ+LK5tkYbbH95F5aOAvjVVP2Vzp9eFrMw@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jonathan.lemon@gmail.com \
    --cc=magnus.karlsson@gmail.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).