From: Jason Wang <jasowang@redhat.com>
To: Toshiaki Makita <toshiaki.makita1@gmail.com>,
Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>,
"David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH net] tun: Fix NULL pointer dereference in XDP redirect
Date: Mon, 28 May 2018 10:24:29 +0800 [thread overview]
Message-ID: <e7222fda-a845-e1ac-f7c2-9a019951af12@redhat.com> (raw)
In-Reply-To: <863681d4-92cf-1575-a182-b07f22ec578e@gmail.com>
On 2018年05月25日 21:43, Toshiaki Makita wrote:
[...]
>>> @@ -1917,16 +1923,22 @@ static ssize_t tun_get_user(struct
>>> tun_struct *tun, struct tun_file *tfile,
>>> struct bpf_prog *xdp_prog;
>>> int ret;
>>> + local_bh_disable();
>>> + preempt_disable();
>>> rcu_read_lock();
>>> xdp_prog = rcu_dereference(tun->xdp_prog);
>>> if (xdp_prog) {
>>> ret = do_xdp_generic(xdp_prog, skb);
>>> if (ret != XDP_PASS) {
>>> rcu_read_unlock();
>>> + preempt_enable();
>>> + local_bh_enable();
>>> return total_len;
>>> }
>>> }
>>> rcu_read_unlock();
>>> + preempt_enable();
>>> + local_bh_enable();
>>> }
>>> rcu_read_lock();
>>
>> Good catch, thanks.
>>
>> But I think we can just replace preempt_disable()/enable() with
>> local_bh_disable()/local_bh_enable() ?
>
> I actually thought the same, but noticed this patch.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9ea4c380066fbe
>
>
> It looks like they do not think local_bh_disable() implies
> preempt_disable(). But I'm not sure why..
>
> Toshiaki Makita
I see, there're probably have some subtle differences and implications
for e.g scheduler or others.
What we what here is to make sure the process is not moved to another
CPU and bh is enabled. By checking preemptible() function, preemption
should be disabled after local_bh_disable(). So I think we're safe here.
Thanks
next prev parent reply other threads:[~2018-05-28 2:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-25 4:32 [PATCH net] tun: Fix NULL pointer dereference in XDP redirect Toshiaki Makita
2018-05-25 9:59 ` Jason Wang
2018-05-25 13:43 ` Toshiaki Makita
2018-05-28 2:24 ` Jason Wang [this message]
2018-05-28 4:28 ` Toshiaki Makita
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=e7222fda-a845-e1ac-f7c2-9a019951af12@redhat.com \
--to=jasowang@redhat.com \
--cc=davem@davemloft.net \
--cc=makita.toshiaki@lab.ntt.co.jp \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=toshiaki.makita1@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.