In the Linux kernel, the following vulnerability has been resolved:
bpf, test_run: Fix use-after-free issue in eth_skb_pkt_type()
KMSAN reported a use-after-free issue in eth_skb_pkt_type()[1]. The
cause of the issue was that eth_skb_pkt_type() accessed skb's data
that didn't contain an Ethernet header. This occurs when
bpf_prog_test_run_xdp() passes an invalid value as the user_data
argument to bpf_test_init().
Fix this by returning an error when user_data is less than ETH_HLEN in
bpf_test_init(). Additionally, remove the check for "if (user_size >
size)" as it is unnecessary.
[1]
BUG: KMSAN: use-after-free in eth_skb_pkt_type include/linux/etherdevice.h:627[inline]BUG: KMSAN: use-after-free in eth_type_trans+0x4ee/0x980net/ethernet/eth.c:165eth_skb_pkt_typeinclude/linux/etherdevice.h:627[inline]eth_type_trans+0x4ee/0x980net/ethernet/eth.c:165__xdp_build_skb_from_frame+0x5a8/0xa50net/core/xdp.c:635xdp_recv_framesnet/bpf/test_run.c:272[inline]xdp_test_run_batchnet/bpf/test_run.c:361[inline]bpf_test_run_xdp_live+0x2954/0x3330net/bpf/test_run.c:390bpf_prog_test_run_xdp+0x148e/0x1b10net/bpf/test_run.c:1318bpf_prog_test_run+0x5b7/0xa30kernel/bpf/syscall.c:4371__sys_bpf+0x6a6/0xe20kernel/bpf/syscall.c:5777__do_sys_bpfkernel/bpf/syscall.c:5866[inline]__se_sys_bpfkernel/bpf/syscall.c:5864[inline]__x64_sys_bpf+0xa4/0xf0kernel/bpf/syscall.c:5864x64_sys_call+0x2ea0/0x3d90arch/x86/include/generated/asm/syscalls_64.h:322do_syscall_x64arch/x86/entry/common.c:52[inline]do_syscall_64+0xd9/0x1d0arch/x86/entry/common.c:83entry_SYSCALL_64_after_hwframe+0x77/0x7fUninit was created at:free_pages_preparemm/page_alloc.c:1056[inline]free_unref_page+0x156/0x1320mm/page_alloc.c:2657__free_pages+0xa3/0x1b0mm/page_alloc.c:4838bpf_ringbuf_freekernel/bpf/ringbuf.c:226[inline]ringbuf_map_free+0xff/0x1e0kernel/bpf/ringbuf.c:235bpf_map_freekernel/bpf/syscall.c:838[inline]bpf_map_free_deferred+0x17c/0x310kernel/bpf/syscall.c:862process_one_workkernel/workqueue.c:3229[inline]process_scheduled_works+0xa2b/0x1b60kernel/workqueue.c:3310worker_thread+0xedf/0x1550kernel/workqueue.c:3391kthread+0x535/0x6b0kernel/kthread.c:389ret_from_fork+0x6e/0x90arch/x86/kernel/process.c:147ret_from_fork_asm+0x1a/0x30arch/x86/entry/entry_64.S:244CPU: 1 UID: 0 PID: 17276 Comm: syz.1.16450 Not tainted 6.12.0-05490-g9bb88c659673 #8
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-3.fc41 04/01/2014