From: John Fastabend <john.fastabend@gmail.com>
To: Daniel Borkmann <daniel@iogearbox.net>, davem@davemloft.net
Cc: ast@fb.com, netdev@vger.kernel.org
Subject: Re: [PATCH net-next 1/2] bpf: don't enable preemption twice in smap_do_verdict
Date: Thu, 17 Aug 2017 09:03:25 -0700 [thread overview]
Message-ID: <5995BE4D.10503@gmail.com> (raw)
In-Reply-To: <d90eed71c2a723edd75f19fb1b921fec74d8a514.1502983087.git.daniel@iogearbox.net>
On 08/17/2017 08:22 AM, Daniel Borkmann wrote:
> In smap_do_verdict(), the fall-through branch leads to call
> preempt_enable() twice for the SK_REDIRECT, which creates an
> imbalance. Only enable it for all remaining cases again.
>
> Fixes: 174a79ff9515 ("bpf: sockmap with sk redirect support")
> Reported-by: Alexei Starovoitov <ast@kernel.org>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> ---
> kernel/bpf/sockmap.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c
> index f7e5e6c..39de541 100644
> --- a/kernel/bpf/sockmap.c
> +++ b/kernel/bpf/sockmap.c
> @@ -135,7 +135,8 @@ static void smap_do_verdict(struct smap_psock *psock, struct sk_buff *skb)
> /* Fall through and free skb otherwise */
> case SK_DROP:
> default:
> - preempt_enable();
> + if (rc != SK_REDIRECT)
> + preempt_enable();
> kfree_skb(skb);
> }
> }
>
Yep looks good, nice catch Alexei. Thanks! I'll add a selftests entry
in test_maps to catch this fall through case. Looks like we don't hit
this case during selftests at the moment.
Acked-by: John Fastabend <john.fastabend@gmail.com>
next prev parent reply other threads:[~2017-08-17 16:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-17 15:22 [PATCH net-next 0/2] Two BPF smap related followups Daniel Borkmann
2017-08-17 15:22 ` [PATCH net-next 1/2] bpf: don't enable preemption twice in smap_do_verdict Daniel Borkmann
2017-08-17 16:03 ` John Fastabend [this message]
2017-08-17 16:10 ` Alexei Starovoitov
2017-08-17 15:22 ` [PATCH net-next 2/2] bpf: reuse tc bpf prologue for sk skb progs Daniel Borkmann
2017-08-17 16:05 ` John Fastabend
2017-08-17 16:12 ` Alexei Starovoitov
2017-08-17 17:25 ` [PATCH net-next 0/2] Two BPF smap related followups David Miller
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=5995BE4D.10503@gmail.com \
--to=john.fastabend@gmail.com \
--cc=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--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 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.