Hou Tao
69e67cef8e
UPSTREAM: bpf: Check rcu_read_lock_trace_held() before calling bpf map helpers
commit 169410eba271afc9f0fb476d996795aa26770c6d upstream.
These three bpf_map_{lookup,update,delete}_elem() helpers are also
available for sleepable bpf program, so add the corresponding lock
assertion for sleepable bpf program, otherwise the following warning
will be reported when a sleepable bpf program manipulates bpf map under
interpreter mode (aka bpf_jit_enable=0):
WARNING: CPU: 3 PID: 4985 at kernel/bpf/helpers.c:40 ......
CPU: 3 PID: 4985 Comm: test_progs Not tainted 6.6.0+ #2
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) ......
RIP: 0010:bpf_map_lookup_elem+0x54/0x60
......
Call Trace:
<TASK>
? __warn+0xa5/0x240
? bpf_map_lookup_elem+0x54/0x60
? report_bug+0x1ba/0x1f0
? handle_bug+0x40/0x80
? exc_invalid_op+0x18/0x50
? asm_exc_invalid_op+0x1b/0x20
? __pfx_bpf_map_lookup_elem+0x10/0x10
? rcu_lockdep_current_cpu_online+0x65/0xb0
? rcu_is_watching+0x23/0x50
? bpf_map_lookup_elem+0x54/0x60
? __pfx_bpf_map_lookup_elem+0x10/0x10
___bpf_prog_run+0x513/0x3b70
__bpf_prog_run32+0x9d/0xd0
? __bpf_prog_enter_sleepable_recur+0xad/0x120
? __bpf_prog_enter_sleepable_recur+0x3e/0x120
bpf_trampoline_6442580665+0x4d/0x1000
__x64_sys_getpgid+0x5/0x30
? do_syscall_64+0x36/0xb0
entry_SYSCALL_64_after_hwframe+0x6e/0x76
</TASK>
Change-Id: I7115c540db6711a3ae1b55246b6fd036abe58308
Signed-off-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20231204140425.1480317-2-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
[Minor conflict resolved due to code context change.]
Signed-off-by: Cliff Liu <donghua.liu@windriver.com>
Signed-off-by: He Zhe <Zhe.He@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-08-28 03:28:59 +03:00
..
2025-08-28 03:28:59 +03:00
2025-08-28 03:26:34 +03:00
2024-10-01 11:50:22 +03:00
2024-10-01 11:50:22 +03:00
2025-08-28 03:27:18 +03:00
2024-07-06 10:19:40 +00:00
2024-08-06 00:36:59 +03:00
2025-08-28 03:25:52 +03:00
2024-10-09 03:14:26 +03:00
2024-05-07 22:02:57 +03:00
2025-08-28 03:26:34 +03:00
2025-08-28 03:27:50 +03:00
2025-08-28 03:26:34 +03:00
2025-08-28 03:26:34 +03:00
2025-08-28 03:28:35 +03:00
2023-01-18 11:30:34 +01:00
2023-08-11 11:45:01 +02:00
2022-09-05 10:26:28 +02:00
2023-11-28 16:46:34 +00:00
2024-02-23 08:12:44 +01:00
2023-09-23 10:48:04 +02:00
2025-03-31 10:08:57 -04:00
2023-04-05 11:15:39 +02:00
2020-10-14 20:04:29 +05:30
2023-12-19 09:45:25 +00:00
2024-03-15 12:38:56 +00:00
2025-08-28 03:27:31 +03:00
2025-08-28 03:26:22 +03:00
2020-11-24 13:27:23 +01:00
2025-08-28 03:27:50 +03:00
2023-08-11 11:45:01 +02:00
2025-08-28 03:26:58 +03:00
2025-08-28 03:25:44 +03:00
2021-03-04 09:39:30 +01:00
2025-03-31 10:08:57 -04:00
2025-08-28 03:24:03 +03:00
2023-08-11 11:45:06 +02:00
2023-06-21 15:39:57 +02:00
2024-01-29 15:46:25 +00:00
2025-08-28 03:26:34 +03:00
2024-11-09 11:24:17 +00:00
2025-08-28 03:26:34 +03:00
2025-08-28 03:27:31 +03:00
2025-08-28 03:26:58 +03:00
2020-07-24 22:21:24 -07:00
2023-11-30 09:36:03 +00:00
2023-02-08 17:19:24 +02:00
2024-06-17 09:34:03 +00:00
2025-08-28 03:26:34 +03:00
2022-08-25 11:15:20 +02:00
2022-06-14 16:59:14 +02:00
2020-11-19 12:25:33 +01:00
2023-05-17 11:13:23 +02:00
2025-08-28 03:26:34 +03:00
2024-12-16 01:21:42 +02:00
2024-10-09 03:14:26 +03:00
2021-02-07 14:48:38 +01:00
2025-08-28 03:24:59 +03:00
2025-08-28 03:27:09 +03:00
2022-09-21 10:22:14 +02:00
2024-05-03 06:16:46 +00:00
2025-08-28 03:26:36 +03:00
2025-08-28 03:28:34 +03:00
2022-02-23 11:58:39 +01:00
2025-08-28 03:27:30 +03:00
2022-05-11 07:51:40 +05:30
2025-08-28 03:28:30 +03:00
2025-08-28 03:26:34 +03:00
2024-08-19 05:32:05 +02:00
2025-08-28 03:26:34 +03:00
2023-11-09 14:55:01 +02:00