Netdev List
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: John Fastabend <john.fastabend@gmail.com>,
	maciej.fijalkowski@intel.com, ast@kernel.org,
	daniel@iogearbox.net, andriin@fb.com
Cc: john.fastabend@gmail.com, netdev@vger.kernel.org, netdev@vger.kernel.org
Subject: RE: [PATCH bpf v2 2/4] bpf: map_poke_descriptor is being called with an unstable poke_tab[]
Date: Wed, 16 Jun 2021 16:42:57 -0700	[thread overview]
Message-ID: <60ca8c81708a9_26dfd2081e@john-XPS-13-9370.notmuch> (raw)
In-Reply-To: <162388411986.151936.3914295553899556046.stgit@john-XPS-13-9370>

John Fastabend wrote:
> When populating poke_tab[] of a subprog we call map_poke_track() after
> doing bpf_jit_add_poke_descriptor(). But, bpf_jit_add_poke_descriptor()
> may, likely will, realloc the poke_tab[] structure and free the old
> one. So that prog->aux->poke_tab is not stable. However, the aux pointer
> is referenced from bpf_array_aux and poke_tab[] is used to 'track'
> prog<->map link. This way when progs are released the entry in the
> map is dropped and vice versa when the map is released we don't drop
> it too soon if a prog is in the process of calling it.
> 
> I wasn't able to trigger any errors here, for example having map_poke_run
> run with a poke_tab[] pointer that was free'd from
> bpf_jit_add_poke_descriptor(), but it looks possible and at very least
> is very fragile.
> 
> This patch moves poke_track call out of loop that is calling add_poke
> so that we only ever add stable aux->poke_tab pointers to the map's
> bpf_array_aux struct. Further, we need this in the next patch to fix
> a real bug where progs are not 'untracked'.
> 
> Signed-off-by: John Fastabend <john.fastabend@gmail.com>
> ---

Needs a fixes tag,

Fixes: a748c6975dea3 ("bpf: propagate poke descriptors to subprograms")

  reply	other threads:[~2021-06-16 23:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16 22:54 [PATCH bpf v2 0/4] BPF fixes mixed tail and bpf2bpf calls John Fastabend
2021-06-16 22:55 ` [PATCH bpf v2 1/4] bpf: Fix null ptr deref with mixed tail calls and subprogs John Fastabend
2021-06-16 22:55 ` [PATCH bpf v2 2/4] bpf: map_poke_descriptor is being called with an unstable poke_tab[] John Fastabend
2021-06-16 23:42   ` John Fastabend [this message]
2021-06-22 21:54   ` Alexei Starovoitov
2021-06-22 22:59     ` John Fastabend
2021-06-16 22:55 ` [PATCH bpf v2 3/4] bpf: track subprog poke correctly John Fastabend
2021-06-22 22:00   ` Alexei Starovoitov
2021-06-22 23:02     ` John Fastabend
2021-06-22 23:07       ` Alexei Starovoitov
2021-06-16 22:55 ` [PATCH bpf v2 4/4] bpf: selftest to verify mixing bpf2bpf calls and tailcalls with insn patch John Fastabend
2021-06-17  4:30 ` [PATCH bpf v2 0/4] BPF fixes mixed tail and bpf2bpf calls 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=60ca8c81708a9_26dfd2081e@john-XPS-13-9370.notmuch \
    --to=john.fastabend@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=maciej.fijalkowski@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