]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: fix incorrect kmalloc usage in lpm_trie MAP_GET_NEXT_KEY rcu region
authorYonghong Song <yhs@fb.com>
Tue, 23 Jan 2018 06:53:51 +0000 (22:53 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 23 Jan 2018 16:33:57 +0000 (17:33 +0100)
commitf49313dfa7b14790a1353782767a0237f664ef18
tree8758454fd5163b0ede4fa9a925b797d9e67d30aa
parent52aa944ca2b77abdc2093e1b6f7249eb71564ae0
bpf: fix incorrect kmalloc usage in lpm_trie MAP_GET_NEXT_KEY rcu region

In commit 93e5248d3ebb ("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: 93e5248d3ebb ("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>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/lpm_trie.c