[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240912143029.x5iudw-g@linutronix.de>
Date: Thu, 12 Sep 2024 16:30:29 +0200
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: Breno Leitao <leitao@...ian.org>
Cc: Vadim Fedorenko <vadim.fedorenko@...ux.dev>,
Jakub Kicinski <kuba@...nel.org>, andrii@...nel.org, ast@...nel.org,
syzbot <syzbot+08811615f0e17bc6708b@...kaller.appspotmail.com>,
bpf@...r.kernel.org, daniel@...earbox.net, davem@...emloft.net,
eddyz87@...il.com, haoluo@...gle.com, hawk@...nel.org,
john.fastabend@...il.com, jolsa@...nel.org, kpsingh@...nel.org,
linux-kernel@...r.kernel.org, martin.lau@...ux.dev,
netdev@...r.kernel.org, sdf@...ichev.me, song@...nel.org,
syzkaller-bugs@...glegroups.com, yonghong.song@...ux.dev
Subject: Re: [PATCH net-net] tun: Assign missing bpf_net_context.
On 2024-09-12 07:19:54 [-0700], Breno Leitao wrote:
> Hello Vadim,
>
> On Thu, Sep 12, 2024 at 02:32:55PM +0100, Vadim Fedorenko wrote:
> > On 12/09/2024 14:17, Breno Leitao wrote:
> > > @@ -72,6 +73,7 @@ static netdev_tx_t netkit_xmit(struct sk_buff *skb, struct net_device *dev)
> > > struct net_device *peer;
> > > int len = skb->len;
> > > + bpf_net_ctx = bpf_net_ctx_set(&__bpf_net_ctx);
> > > rcu_read_lock();
> >
> > Hi Breno,
> >
> > looks like bpf_net_ctx should be set under rcu read lock...
>
> Why exactly?
>
> I saw in some examples where bpf_net_ctx_set() was set inside the
> rcu_read_lock(), but, I was not able to come up with justification to do
> the same. Would you mind elaborating why this might be needed inside the
> lock?
It might have been done due to simpler nesting or other reasons but
there is no requirement to do this under RCU protection. The assignment
and cleanup is always performed task-local.
> Thanks for the review,
> --breno
Sebastian
Powered by blists - more mailing lists