Re: BUG: unable to handle kernel paging request in bpf_check

From: Alexei Starovoitov
Date: Mon Apr 12 2021 - 13:08:59 EST


On Mon, Apr 12, 2021 at 12:11 AM Hao Sun <sunhao.th@xxxxxxxxx> wrote:
>
> Besides, another similar bug occurred while fault injection was enabled.
> ====
> BUG: unable to handle kernel paging request in bpf_prog_alloc_no_stats
> ========================================================
> RAX: ffffffffffffffda RBX: 000000000059c080 RCX: 000000000047338d
> RDX: 0000000000000078 RSI: 0000000020000300 RDI: 0000000000000005
> RBP: 00007f7e3c38fc90 R08: 0000000000000000 R09: 0000000000000000
> R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000004
> R13: 00007ffed3a1dd6f R14: 00007ffed3a1df10 R15: 00007f7e3c38fdc0
> BUG: unable to handle page fault for address: ffff91f2077ed028
> #PF: supervisor write access in kernel mode
> #PF: error_code(0x0002) - not-present page
> PGD 1810067 P4D 1810067 PUD 1915067 PMD 3b907067 PTE 0
> Oops: 0002 [#1] SMP
> CPU: 3 PID: 17344 Comm: executor Not tainted 5.12.0-rc6+ #1
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
> 1.13.0-1ubuntu1.1 04/01/2014
> RIP: 0010:bpf_prog_alloc_no_stats+0x251/0x6e0 kernel/bpf/core.c:94

Both crashes don't make much sense.
There are !null checks in both cases.
I suspect it's a kmsan bug.
Most likely kmsan_map_kernel_range_noflush is doing something wrong.
No idea where that function lives. I don't see it in the kernel sources.