public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: Daniel Borkmann <daniel@iogearbox.net>,
	 Eric Dumazet <edumazet@google.com>
Cc: davem@davemloft.net,  kuba@kernel.org,  pabeni@redhat.com,
	 ast@kernel.org,  andrii@kernel.org,  martin.lau@linux.dev,
	 netdev@vger.kernel.org,  bpf@vger.kernel.org,
	 john.fastabend@gmail.com,  jakub@cloudflare.com
Subject: Re: pull-request: bpf 2023-11-30
Date: Thu, 30 Nov 2023 07:54:36 -0800	[thread overview]
Message-ID: <6568b03cbceb7_1b8920827@john.notmuch> (raw)
In-Reply-To: <edef4d8b-8682-c23f-31c4-57546be97299@iogearbox.net>

Daniel Borkmann wrote:
> On 11/30/23 3:53 PM, Eric Dumazet wrote:
> > On Thu, Nov 30, 2023 at 12:49 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
> >>
> >> Hi David, hi Jakub, hi Paolo, hi Eric,
> >>
> >> The following pull-request contains BPF updates for your *net* tree.
> >>
> >> We've added 5 non-merge commits during the last 7 day(s) which contain
> >> a total of 10 files changed, 66 insertions(+), 15 deletions(-).
> >>
> >> The main changes are:
> >>
> >> 1) Fix AF_UNIX splat from use after free in BPF sockmap, from John Fastabend.
> > 
> > syzbot is not happy with this patch.
> > 
> > Would the following fix make sense?
> > 
> > diff --git a/net/unix/unix_bpf.c b/net/unix/unix_bpf.c
> > index 7ea7c3a0d0d06224f49ad5f073bf772b9528a30a..58e89361059fbf9d5942c6dd268dd80ac4b57098
> > 100644
> > --- a/net/unix/unix_bpf.c
> > +++ b/net/unix/unix_bpf.c
> > @@ -168,7 +168,8 @@ int unix_stream_bpf_update_proto(struct sock *sk,
> > struct sk_psock *psock, bool r
> >          }
> > 
> >          sk_pair = unix_peer(sk);
> > -       sock_hold(sk_pair);
> > +       if (sk_pair)
> > +               sock_hold(sk_pair);
> >          psock->sk_pair = sk_pair;
> >          unix_stream_bpf_check_needs_rebuild(psock->sk_proto);
> >          sock_replace_proto(sk, &unix_stream_bpf_prot);
> > 
> 
> Oh well :/ Above looks reasonable to me, thanks, but I'll defer to John & Jakub (both Cc'ed)
> for a final look.
> 
> Thanks,
> Daniel

Is that sk in LISTEN state by any chance? I can't think why we even allow such a
thing for af_unix sockets.  Another possible fix would be to block adding these
to sockmap at all.

But, above should be fine as well so I would just go with that. Eric or Daniel
would you like to submit a patch or I can if needed.

Thanks,
John

  reply	other threads:[~2023-11-30 15:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-29 23:49 pull-request: bpf 2023-11-30 Daniel Borkmann
2023-11-30  3:50 ` patchwork-bot+netdevbpf
2023-11-30 14:53 ` Eric Dumazet
2023-11-30 15:04   ` Daniel Borkmann
2023-11-30 15:54     ` John Fastabend [this message]
2023-11-30 16:04       ` Eric Dumazet
2023-11-30 16:19         ` Eric Dumazet
2023-11-30 23:37           ` John Fastabend

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=6568b03cbceb7_1b8920827@john.notmuch \
    --to=john.fastabend@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jakub@cloudflare.com \
    --cc=kuba@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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