]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpf: Check rcu_read_lock_trace_held() in bpf_map_lookup_percpu_elem()
authorHou Tao <houtao1@huawei.com>
Mon, 26 May 2025 06:25:34 +0000 (14:25 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:07:32 +0000 (11:07 +0100)
commit2f8c69a72e8ad87b36b8052f789da3cc2b2e186c
tree8ee8d24248c26f2d806b9bbfee2f3118c116979d
parenta1d9dd02f5a343762cdd82b993d462afbbd25d30
bpf: Check rcu_read_lock_trace_held() in bpf_map_lookup_percpu_elem()

[ Upstream commit d4965578267e2e81f67c86e2608481e77e9c8569 ]

bpf_map_lookup_percpu_elem() helper is also available for sleepable bpf
program. When BPF JIT is disabled or under 32-bit host,
bpf_map_lookup_percpu_elem() will not be inlined. Using it in a
sleepable bpf program will trigger the warning in
bpf_map_lookup_percpu_elem(), because the bpf program only holds
rcu_read_lock_trace lock. Therefore, add the missed check.

Reported-by: syzbot+dce5aae19ae4d6399986@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/bpf/000000000000176a130617420310@google.com/
Signed-off-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20250526062534.1105938-1-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/helpers.c