netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeongjun Park <aha310510@gmail.com>
To: pabeni@redhat.com
Cc: aha310510@gmail.com, bigeasy@linutronix.de, bpf@vger.kernel.org,
	davem@davemloft.net, edumazet@google.com, jasowang@redhat.com,
	jiri@resnulli.us, kuba@kernel.org, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org,
	syzbot+44623300f057a28baf1e@syzkaller.appspotmail.com,
	syzkaller-bugs@googlegroups.com, willemdebruijn.kernel@gmail.com
Subject: Re: [PATCH net] tun: Remove nested call to bpf_net_ctx_set() in do_xdp_generic()
Date: Thu, 25 Jul 2024 21:15:06 +0900	[thread overview]
Message-ID: <20240725121506.15501-1-aha310510@gmail.com> (raw)
In-Reply-To: <e263f723-0b9c-4059-982d-2bb4b5636759@redhat.com>

Paolo Abeni wrote:
>
> On 7/25/24 04:43, Willem de Bruijn wrote:
> > Jeongjun Park wrote:
> >> In the previous commit, bpf_net_context handling was added to
> >> tun_sendmsg() and do_xdp_generic(), but if you write code like this,
> >> bpf_net_context overlaps in the call trace below, causing various
> >> memory corruptions.
> >
> > I'm no expert on this code, but commit 401cb7dae813 that introduced
> > bpf_net_ctx_set explicitly states that nested calls are allowed.
> >
> > And the function does imply that:
> >
> > static inline struct bpf_net_context *bpf_net_ctx_set(struct bpf_net_context *bpf_net_ctx)
> > {
> >          struct task_struct *tsk = current;
> >
> >          if (tsk->bpf_net_context != NULL)
> >                  return NULL;
> >          bpf_net_ctx->ri.kern_flags = 0;
> >
> >          tsk->bpf_net_context = bpf_net_ctx;
> >          return bpf_net_ctx;
> > }
>
> I agree with Willem, the ctx nesting looks legit generally speaking.
> @Jeongjun: you need to track down more accurately the issue root cause
> and include such info into the commit message.
>
> Skimming over the code I *think* do_xdp_generic() is not cleaning the
> nested context in all the paths before return and that could cause the
> reported issue.

Thanks to your comment, I re-read the code and found the root cause.
I will send a patch for that bug.

Regards,
Jeongjun Park

  reply	other threads:[~2024-07-25 12:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-19  3:59 [syzbot] [net?] [bpf?] general protection fault in __dev_flush syzbot
2024-07-22  2:59 ` [syzbot] [bpf?] [net?] " syzbot
2024-07-24 15:21   ` [PATCH net] tun: Remove nested call to bpf_net_ctx_set() in do_xdp_generic() Jeongjun Park
2024-07-25  2:43     ` Willem de Bruijn
2024-07-25  4:13       ` Jeongjun Park
2024-07-25 10:44       ` Paolo Abeni
2024-07-25 12:15         ` Jeongjun Park [this message]
2024-07-25 21:40 ` [PATCH net] tun: Add missing bpf_net_ctx_clear() " Jeongjun Park
2024-07-26  2:21   ` Jason Wang
2024-07-26  3:03     ` Willem de Bruijn
2024-07-26 14:41   ` Jakub Kicinski
2024-07-27  2:16     ` Jeongjun Park
2024-07-27  2:28   ` Jeongjun Park
2024-07-29 10:08   ` patchwork-bot+netdevbpf

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=20240725121506.15501-1-aha310510@gmail.com \
    --to=aha310510@gmail.com \
    --cc=bigeasy@linutronix.de \
    --cc=bpf@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jasowang@redhat.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=syzbot+44623300f057a28baf1e@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=willemdebruijn.kernel@gmail.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;
as well as URLs for NNTP newsgroup(s).