From: Eric Dumazet <eric.dumazet@gmail.com>
To: Yonghong Song <yhs@fb.com>,
ast@fb.com, daniel@iogearbox.net, netdev@vger.kernel.org
Cc: kernel-team@fb.com
Subject: Re: [PATCH bpf-next] bpf: fix incorrect kmalloc usage in lpm_trie MAP_GET_NEXT_KEY rcu region
Date: Tue, 23 Jan 2018 07:50:49 -0800 [thread overview]
Message-ID: <1516722649.3478.15.camel@gmail.com> (raw)
In-Reply-To: <20180123065351.2690530-1-yhs@fb.com>
On Mon, 2018-01-22 at 22:53 -0800, Yonghong Song wrote:
> In commit b471f2f1de8b ("bpf: implement MAP_GET_NEXT_KEY command for LPM_TRIE map"),
> the implemented MAP_GET_NEXT_KEY callback function is guarded with rcu read lock.
> In the function body, "kmalloc(size, GFP_USER | __GFP_NOWARN)" is used which may
> sleep and violate rcu read lock region requirements. This patch fixed the issue
> by using GFP_ATOMIC instead to avoid blocking kmalloc. Tested with
> CONFIG_DEBUG_ATOMIC_SLEEP=y as suggested by Eric Dumazet.
>
> Fixes: b471f2f1de8b ("bpf: implement MAP_GET_NEXT_KEY command for LPM_TRIE map")
> Signed-off-by: Yonghong Song <yhs@fb.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Thanks.
> ---
> kernel/bpf/lpm_trie.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/lpm_trie.c b/kernel/bpf/lpm_trie.c
> index d7ea962..8f083ea 100644
> --- a/kernel/bpf/lpm_trie.c
> +++ b/kernel/bpf/lpm_trie.c
> @@ -624,7 +624,7 @@ static int trie_get_next_key(struct bpf_map *map, void *_key, void *_next_key)
> }
>
> node_stack = kmalloc(trie->max_prefixlen * sizeof(struct lpm_trie_node *),
> - GFP_USER | __GFP_NOWARN);
> + GFP_ATOMIC | __GFP_NOWARN);
> if (!node_stack)
> return -ENOMEM;
>
next prev parent reply other threads:[~2018-01-23 15:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-23 6:53 [PATCH bpf-next] bpf: fix incorrect kmalloc usage in lpm_trie MAP_GET_NEXT_KEY rcu region Yonghong Song
2018-01-23 15:50 ` Eric Dumazet [this message]
2018-01-23 16:35 ` Daniel Borkmann
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=1516722649.3478.15.camel@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
--cc=yhs@fb.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.