[v5.15] WARNING: suspicious RCU usage in get_callchain_entry

1 view
Skip to first unread message

syzbot

unread,
Jun 13, 2024, 2:30:24 PM6/13/24
Hello,

syzbot found the following issue on:

HEAD commit: c61bd26ae81a Linux 5.15.160
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=152e3246980000
kernel config: https://syzkaller.appspot.com/x/.config?x=235f0e81ca937c17
dashboard link: https://syzkaller.appspot.com/bug?extid=fc37d916410f29b8588d
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/d61a97eef8b9/disk-c61bd26a.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/ab4908b4b59b/vmlinux-c61bd26a.xz
kernel image: https://storage.googleapis.com/syzbot-assets/d818fd46802b/bzImage-c61bd26a.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

=============================
WARNING: suspicious RCU usage
5.15.160-syzkaller #0 Not tainted
-----------------------------
kernel/events/callchain.c:161 suspicious rcu_dereference_check() usage!

other info that might help us debug this:


rcu_scheduler_active = 2, debug_locks = 1
1 lock held by syz-executor.0/3900:
#0: ffffffff8c920280 (rcu_read_lock_trace){....}-{0:0}, at: rcu_lock_acquire+0x9/0x30 include/linux/rcupdate.h:312

stack backtrace:
CPU: 1 PID: 3900 Comm: syz-executor.0 Not tainted 5.15.160-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
get_callchain_entry+0x2ac/0x3c0 kernel/events/callchain.c:161
get_perf_callchain+0xe6/0x810 kernel/events/callchain.c:187
__bpf_get_stack+0x378/0x570 kernel/bpf/stackmap.c:482
____bpf_get_stack_raw_tp kernel/trace/bpf_trace.c:1490 [inline]
bpf_get_stack_raw_tp+0x1b2/0x220 kernel/trace/bpf_trace.c:1480
bpf_prog_d43750871481577d+0x3d/0x77c
bpf_dispatcher_nop_func include/linux/bpf.h:790 [inline]
__bpf_prog_run include/linux/filter.h:628 [inline]
bpf_prog_run include/linux/filter.h:635 [inline]
bpf_prog_run_pin_on_cpu+0x62/0x130 include/linux/filter.h:652
bpf_prog_test_run_syscall+0x366/0x550 net/bpf/test_run.c:1055
bpf_prog_test_run+0x32f/0x3a0 kernel/bpf/syscall.c:3368
__sys_bpf+0x3ac/0x670 kernel/bpf/syscall.c:4669
__do_sys_bpf kernel/bpf/syscall.c:4755 [inline]
__se_sys_bpf kernel/bpf/syscall.c:4753 [inline]
__x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:4753
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7fb9e2368ea9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fb9e0ee20c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007fb9e249ff80 RCX: 00007fb9e2368ea9
RDX: 0000000000000010 RSI: 0000000020000740 RDI: 000000000000000a
RBP: 00007fb9e23d7ff4 R


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Jun 13, 2024, 4:14:22 PM6/13/24
syzbot has found a reproducer for the following issue on:

HEAD commit: c61bd26ae81a Linux 5.15.160
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1142cf6a980000
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14ab80ea980000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10cfaf36980000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/d61a97eef8b9/disk-c61bd26a.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/ab4908b4b59b/vmlinux-c61bd26a.xz
kernel image: https://storage.googleapis.com/syzbot-assets/d818fd46802b/bzImage-c61bd26a.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

=============================
WARNING: suspicious RCU usage
5.15.160-syzkaller #0 Not tainted
-----------------------------
kernel/events/callchain.c:161 suspicious rcu_dereference_check() usage!

other info that might help us debug this:


rcu_scheduler_active = 2, debug_locks = 1
1 lock held by syz-executor406/3504:
#0: ffffffff8c920280 (rcu_read_lock_trace){....}-{0:0}, at: rcu_lock_acquire+0x9/0x30 include/linux/rcupdate.h:312

stack backtrace:
CPU: 0 PID: 3504 Comm: syz-executor406 Not tainted 5.15.160-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
get_callchain_entry+0x2ac/0x3c0 kernel/events/callchain.c:161
get_perf_callchain+0xe6/0x810 kernel/events/callchain.c:187
__bpf_get_stack+0x378/0x570 kernel/bpf/stackmap.c:482
____bpf_get_stack_raw_tp kernel/trace/bpf_trace.c:1490 [inline]
bpf_get_stack_raw_tp+0x1b2/0x220 kernel/trace/bpf_trace.c:1480
bpf_prog_d43750871481577d+0x3d/0x9ac
bpf_dispatcher_nop_func include/linux/bpf.h:790 [inline]
__bpf_prog_run include/linux/filter.h:628 [inline]
bpf_prog_run include/linux/filter.h:635 [inline]
bpf_prog_run_pin_on_cpu+0x62/0x130 include/linux/filter.h:652
bpf_prog_test_run_syscall+0x366/0x550 net/bpf/test_run.c:1055
bpf_prog_test_run+0x32f/0x3a0 kernel/bpf/syscall.c:3368
__sys_bpf+0x3ac/0x670 kernel/bpf/syscall.c:4669
__do_sys_bpf kernel/bpf/syscall.c:4755 [inline]
__se_sys_bpf kernel/bpf/syscall.c:4753 [inline]
__x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:4753
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7fdd78f3efb9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 c1 17 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe99e73df8 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fdd78f3efb9
RDX: 0000000000000010 RSI: 0000000020000740 RDI: 000000000000000a
RBP: 0000000000000000 R08: 0000000000000006 R09: 0000000000000006
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000001 R15: 0000000000000001
</TASK>

=============================
WARNING: suspicious RCU usage
5.15.160-syzkaller #0 Not tainted
-----------------------------
include/linux/perf_event.h:1273 suspicious rcu_dereference_check() usage!

other info that might help us debug this:


rcu_scheduler_active = 2, debug_locks = 1
1 lock held by syz-executor406/3504:
#0: ffffffff8c920280 (rcu_read_lock_trace){....}-{0:0}, at: rcu_lock_acquire+0x9/0x30 include/linux/rcupdate.h:312

stack backtrace:
CPU: 0 PID: 3504 Comm: syz-executor406 Not tainted 5.15.160-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
perf_get_guest_cbs include/linux/perf_event.h:1273 [inline]
perf_callchain_kernel+0x38b/0x6e0 arch/x86/events/core.c:2766
get_perf_callchain+0x579/0x810 kernel/events/callchain.c:200
__bpf_get_stack+0x378/0x570 kernel/bpf/stackmap.c:482
____bpf_get_stack_raw_tp kernel/trace/bpf_trace.c:1490 [inline]
bpf_get_stack_raw_tp+0x1b2/0x220 kernel/trace/bpf_trace.c:1480
bpf_prog_d43750871481577d+0x3d/0x9ac
bpf_dispatcher_nop_func include/linux/bpf.h:790 [inline]
__bpf_prog_run include/linux/filter.h:628 [inline]
bpf_prog_run include/linux/filter.h:635 [inline]
bpf_prog_run_pin_on_cpu+0x62/0x130 include/linux/filter.h:652
bpf_prog_test_run_syscall+0x366/0x550 net/bpf/test_run.c:1055
bpf_prog_test_run+0x32f/0x3a0 kernel/bpf/syscall.c:3368
__sys_bpf+0x3ac/0x670 kernel/bpf/syscall.c:4669
__do_sys_bpf kernel/bpf/syscall.c:4755 [inline]
__se_sys_bpf kernel/bpf/syscall.c:4753 [inline]
__x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:4753
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7fdd78f3efb9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 c1 17 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe99e73df8 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fdd78f3efb9
RDX: 0000000000000010 RSI: 0000000020000740 RDI: 000000000000000a
RBP: 0000000000000000 R08: 0000000000000006 R09: 0000000000000006
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000001 R15: 0000000000000001
</TASK>


---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

syzbot

unread,
Jul 15, 2024, 2:02:48 PM7/15/24
For archival purposes, forwarding an incoming command email to
[email protected].

***

Subject: Test
Author: [email protected]

#syz test

---
include/linux/perf_event.h | 8 +++++++-
kernel/events/callchain.c | 12 +++++++++---
2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 200995c5210e..9d455fd543b9 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -41,6 +41,7 @@ struct perf_guest_info_callbacks {
#include <linux/mutex.h>
#include <linux/rculist.h>
#include <linux/rcupdate.h>
+#include <linux/rcupdate_trace.h>
#include <linux/spinlock.h>
#include <linux/hrtimer.h>
#include <linux/fs.h>
@@ -1269,8 +1270,13 @@ static inline struct perf_guest_info_callbacks *perf_get_guest_cbs(void)
* pending stores/changes to the callback pointers are visible before a
* non-NULL perf_guest_cbs is visible to readers, and to prevent a
* module from unloading callbacks while readers are active.
+ *
+ * BPF locked rcu using rcu_read_lock_trace() in
+ * bpf_prog_test_run_syscall()
*/
- return rcu_dereference(perf_guest_cbs);
+ return rcu_dereference_check(perf_guest_cbs,
+ rcu_read_lock_trace_held() ||
+ rcu_read_lock_held());
}
extern int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks);
extern int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks);
diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c
index 58cbe357fb2b..e47402c97ae0 100644
--- a/kernel/events/callchain.c
+++ b/kernel/events/callchain.c
@@ -11,6 +11,7 @@
#include <linux/perf_event.h>
#include <linux/slab.h>
#include <linux/sched/task_stack.h>
+#include <linux/rcupdate_trace.h>

#include "internal.h"

@@ -32,7 +33,7 @@ static inline size_t perf_callchain_entry__sizeof(void)
static DEFINE_PER_CPU(int, callchain_recursion[PERF_NR_CONTEXTS]);
static atomic_t nr_callchain_events;
static DEFINE_MUTEX(callchain_mutex);
-static struct callchain_cpus_entries *callchain_cpus_entries;
+static struct callchain_cpus_entries __rcu *callchain_cpus_entries;


__weak void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
@@ -157,8 +158,13 @@ struct perf_callchain_entry *get_callchain_entry(int *rctx)
*rctx = get_recursion_context(this_cpu_ptr(callchain_recursion));
if (*rctx == -1)
return NULL;
-
- entries = rcu_dereference(callchain_cpus_entries);
+ /*
+ * BPF locked rcu using rcu_read_lock_trace() in
+ * bpf_prog_test_run_syscall()
+ */
+ entries = rcu_dereference_check(callchain_cpus_entries,
+ rcu_read_lock_trace_held() ||
+ rcu_read_lock_held());
if (!entries) {
put_recursion_context(this_cpu_ptr(callchain_recursion), *rctx);
return NULL;
--
2.43.0

Reply all
Reply to author
Forward
0 new messages