Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2755B142E67 for ; Mon, 26 Aug 2024 10:24:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724667841; cv=none; b=We2JAiVhOih8z5+DVy5ESKGZEvU4zwFXWiUhEZ0QDnNG7yXMtDCsEVNAQAWN66ogxj6+ikaaT30HvWJSN4qrhQpcjBDHvAxYIAOvlavEieazpWnmY8n9xhExrypP4xfTcWZirHRZmK2Rr2mIY/GegvBQD2oOiXKlegV01afrTX0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724667841; c=relaxed/simple; bh=wEEQ4RhsB/uZ69p6szYxF7cGvgoZIe/RhCN6qMgGL/s=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=U6h5nnF++NjMMbNWdjF1gEEEVRvVmIgyfw2Xhc8pfFJwjcQOTEYi+VjjI3LM6+epAH2hdVR8Q3w2NtVRNewNwqCPO7y2W+AQ2cLaXnYDN4HDoaz9rTIF7FrEMokX2KlHmn8daE4LfsZ9QGu8zCzEUwN2HHvVMnBOrT6Mk+F2+uo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=JXcum/HS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="JXcum/HS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2051C5E8A4; Mon, 26 Aug 2024 10:24:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1724667841; bh=wEEQ4RhsB/uZ69p6szYxF7cGvgoZIe/RhCN6qMgGL/s=; h=From:To:Cc:Subject:Date:Reply-to:From; b=JXcum/HSdXrG5HPnFyalxh45peGJyfhzkqVqIo145SHsSIqQz95zqLLZakgbOgMCf RAc2ohAOG90dDAGqEu3Q8KQzVOckb4uRkEwboLvfIM1K/f49XNxPt993cILZCMdBmm lnrHSQzNthmhxldgMyw15Uxnv6+vc3BFOIRwVrt8= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-43910: bpf: add missing check_func_arg_reg_off() to prevent out-of-bounds memory accesses Date: Mon, 26 Aug 2024 12:17:18 +0200 Message-ID: <2024082630-CVE-2024-43910-c6ec@gregkh> X-Mailer: git-send-email 2.46.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=4419; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=wEEQ4RhsB/uZ69p6szYxF7cGvgoZIe/RhCN6qMgGL/s=; b=owGbwMvMwCRo6H6F97bub03G02pJDGlnwqz4DYWte3y/fPiyqv/+o1Blu8TWKo+OlCuiezcsy bprcbqjI5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACbSIMIwz1I8b9dv5m0lV+Ja L94MrvzlcfSVH8P89LJPV320JW6wXg1umRa+S0H/gG0tAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: bpf: add missing check_func_arg_reg_off() to prevent out-of-bounds memory accesses Currently, it's possible to pass in a modified CONST_PTR_TO_DYNPTR to a global function as an argument. The adverse effects of this is that BPF helpers can continue to make use of this modified CONST_PTR_TO_DYNPTR from within the context of the global function, which can unintentionally result in out-of-bounds memory accesses and therefore compromise overall system stability i.e. [ 244.157771] BUG: KASAN: slab-out-of-bounds in bpf_dynptr_data+0x137/0x140 [ 244.161345] Read of size 8 at addr ffff88810914be68 by task test_progs/302 [ 244.167151] CPU: 0 PID: 302 Comm: test_progs Tainted: G O E 6.10.0-rc3-00131-g66b586715063 #533 [ 244.174318] Call Trace: [ 244.175787] [ 244.177356] dump_stack_lvl+0x66/0xa0 [ 244.179531] print_report+0xce/0x670 [ 244.182314] ? __virt_addr_valid+0x200/0x3e0 [ 244.184908] kasan_report+0xd7/0x110 [ 244.187408] ? bpf_dynptr_data+0x137/0x140 [ 244.189714] ? bpf_dynptr_data+0x137/0x140 [ 244.192020] bpf_dynptr_data+0x137/0x140 [ 244.194264] bpf_prog_b02a02fdd2bdc5fa_global_call_bpf_dynptr_data+0x22/0x26 [ 244.198044] bpf_prog_b0fe7b9d7dc3abde_callback_adjust_bpf_dynptr_reg_off+0x1f/0x23 [ 244.202136] bpf_user_ringbuf_drain+0x2c7/0x570 [ 244.204744] ? 0xffffffffc0009e58 [ 244.206593] ? __pfx_bpf_user_ringbuf_drain+0x10/0x10 [ 244.209795] bpf_prog_33ab33f6a804ba2d_user_ringbuf_callback_const_ptr_to_dynptr_reg_off+0x47/0x4b [ 244.215922] bpf_trampoline_6442502480+0x43/0xe3 [ 244.218691] __x64_sys_prlimit64+0x9/0xf0 [ 244.220912] do_syscall_64+0xc1/0x1d0 [ 244.223043] entry_SYSCALL_64_after_hwframe+0x77/0x7f [ 244.226458] RIP: 0033:0x7ffa3eb8f059 [ 244.228582] Code: 08 89 e8 5b 5d c3 66 2e 0f 1f 84 00 00 00 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 8b 0d 8f 1d 0d 00 f7 d8 64 89 01 48 [ 244.241307] RSP: 002b:00007ffa3e9c6eb8 EFLAGS: 00000206 ORIG_RAX: 000000000000012e [ 244.246474] RAX: ffffffffffffffda RBX: 00007ffa3e9c7cdc RCX: 00007ffa3eb8f059 [ 244.250478] RDX: 00007ffa3eb162b4 RSI: 0000000000000000 RDI: 00007ffa3e9c7fb0 [ 244.255396] RBP: 00007ffa3e9c6ed0 R08: 00007ffa3e9c76c0 R09: 0000000000000000 [ 244.260195] R10: 0000000000000000 R11: 0000000000000206 R12: ffffffffffffff80 [ 244.264201] R13: 000000000000001c R14: 00007ffc5d6b4260 R15: 00007ffa3e1c7000 [ 244.268303] Add a check_func_arg_reg_off() to the path in which the BPF verifier verifies the arguments of global function arguments, specifically those which take an argument of type ARG_PTR_TO_DYNPTR | MEM_RDONLY. Also, process_dynptr_func() doesn't appear to perform any explicit and strict type matching on the supplied register type, so let's also enforce that a register either type PTR_TO_STACK or CONST_PTR_TO_DYNPTR is by the caller. The Linux kernel CVE team has assigned CVE-2024-43910 to this issue. Affected and fixed versions =========================== Fixed in 6.10.5 with commit 13663a7c644b Fixed in 6.11-rc1 with commit ec2b9a5e11e5 Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2024-43910 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: kernel/bpf/verifier.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/13663a7c644bf1dedaf461d07252db5d76c8759a https://git.kernel.org/stable/c/ec2b9a5e11e51fea1bb04c1e7e471952e887e874