CVE-2022-49402 Information
Description
In the Linux kernel the following vulnerability has been resolved:
ftrace: Clean up hash direct_functions on register failures
We see the following GPF when register_ftrace_direct fails:
[ ] general protection fault probably for non-canonical address
0x200000000000010: 0000 [1] PREEMPT SMP DEBUG_PAGEALLOC PTI
[…]
[ ] RIP: 0010:ftrace_find_rec_direct+0x53/0x70
[ ] Code: 48 c1 e0 03 48 03 42 08 48 8b 10 31 c0 48 85 d2 74 […]
[ ] RSP: 0018:ffffc9000138bc10 EFLAGS: 00010206
[ ] RAX: 0000000000000000 RBX: ffffffff813e0df0 RCX: 000000000000003b
[ ] RDX: 0200000000000000 RSI: 000000000000000c RDI: ffffffff813e0df0
[ ] RBP: ffffffffa00a3000 R08: ffffffff81180ce0 R09: 0000000000000001
[ ] R10: ffffc9000138bc18 R11: 0000000000000001 R12: ffffffff813e0df0
[ ] R13: ffffffff813e0df0 R14: ffff888171b56400 R15: 0000000000000000
[ ] FS: 00007fa9420c7780(0000) GS:ffff888ff6a00000(0000) knlGS:000000000
[ ] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ ] CR2: 000000000770d000 CR3: 0000000107d50003 CR4: 0000000000370ee0
[ ] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ ] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ ] Call Trace:
[ ]
One way to trigger this is:
- load a livepatch that patches kernel function xxx;
- run bpftrace -e ‘kfunc:xxx ’ this will fail (expected for now);
- repeat 2 => gpf.
This is because the entry is added to direct_functions but not removed. Fix this by remove the entry from direct_functions when register_ftrace_direct fails.
Also remove the last trailing space from ftrace.c so we don’t have to worry about it anymore.
Reference
https://git.kernel.org/stable/c/7d54c15cb89a29a5f59e5ffc9ee62e6591769ef1 https://git.kernel.org/stable/c/805e87af946d8d2954171361e64d143ff37a441b https://git.kernel.org/stable/c/82c888e51c2176a06f8b4541cf748ee81aac6e7e https://git.kernel.org/stable/c/a0392833a178cf109a57c2a9d4d531bdfc6cd98f https://git.kernel.org/stable/c/cae2978d6907ef2c08b9b15f704e783f7c284713
Share on: