mirror of
https://github.com/dynup/kpatch
synced 2024-12-18 11:24:33 +00:00
f499fc25e0
Yulia reported a bug with module.patch which can be seen with CONFIG_PROVE_RCU: BUG: sleeping function called from invalid context at include/linux/percpu-rwsem.h:49 in_atomic(): 0, irqs_disabled(): 0, non_block: 0, pid: 1053, name: grep preempt_count: 0, expected: 0 RCU nest depth: 1, expected: 0 2 locks held by grep/1053: #0: ffff8881079bf1a0 (&p->lock){+.+.}-{3:3}, at: seq_read_iter+0x55/0x460 #1: ffffffff8275d620 (rcu_read_lock){....}-{1:2}, at: cache_seq_start_rcu+0x5/0x140 [sunrpc] CPU: 3 PID: 1053 Comm: grep Tainted: G OE K 6.2.0 #57 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.1-2.fc37 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x5b/0x77 __might_resched.cold+0xff/0x13a cpus_read_lock+0x16/0xd0 static_key_disable+0xe/0x20 e_show+0x5b/0xd70 [livepatch_module] seq_read_iter+0x127/0x460 seq_read+0xa3/0xd0 proc_reg_read+0x52/0xa0 vfs_read+0xc9/0x2f0 ? __do_sys_newfstat+0x57/0x60 ? lock_is_held_type+0xe8/0x140 ksys_read+0x6c/0xf0 do_syscall_64+0x37/0x90 entry_SYSCALL_64_after_hwframe+0x72/0xdc RIP: 0033:0x7fbd314f7af0 Code: b6 fe ff ff 48 8d 3d 2f 78 09 00 48 83 ec 08 e8 96 25 02 00 66 0f 1f 44 00 00 83 3d d9 db 2c 00 00 75 10 b8 00 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 7e e3 01 00 48 89 04 24 RSP: 002b:00007ffcd6f1c708 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 0000000000008000 RCX: 00007fbd314f7af0 RDX: 0000000000008000 RSI: 0000563c751ea000 RDI: 0000000000000003 RBP: 0000000000008000 R08: 0000000000009008 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000563c751ea000 R13: 0000000000000003 R14: 0000000000000003 R15: 0000563c751ea000 The problem is that the patched module's seq_operations take an RCU read lock before calling e_show(), which is patched to call static_key_disable(), which can sleep. Fix the issue by moving all the module test code to a different module (xfs) which doesn't take an RCU lock. Also enable the pr_debug() test and make the static branch test unconditional since they're supported by newer kernels and this test is for 6.2. Reported-by: Yulia Kopkova <ykopkova@redhat.com> Debugged-by: Joe Lawrence <joe.lawrence@redhat.com> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
10 lines
205 B
Bash
Executable File
10 lines
205 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -o errexit
|
|
|
|
sudo modprobe xfs
|
|
sleep 5
|
|
echo "file fs/xfs/xfs_stats.c +p" > /sys/kernel/debug/dynamic_debug/control
|
|
grep -q kpatch /sys/fs/xfs/stats/stats
|
|
dmesg | grep -q "kpatch: pr_debug"
|