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 1EA6A1B4240 for ; Wed, 26 Feb 2025 01:59:45 +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=1740535185; cv=none; b=m/3DLB1Z3UNedGGOLfDdKVa11ThthK5F4RvHRtZ0BqYhJjG1kclEA2dbWRtbAKDVlxeu90CzExEDdFs4zSQvoCD8nIjOLS6lvaIRs+yOfCbAjwPhuHU1NvQohOvthVpAa3py6yZKG77sah/PCzZSjpngkTwfj5xuMTB2nXhzs2c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740535185; c=relaxed/simple; bh=ASJ0DiR+O+GnD0uEDli+rpyWfGV2cfZuKIgW9a0X4Ko=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Ymh7rZ5acIFi4LVYAFZ5+OYeyKdTMD/2Zx8flFsOriYuNIG9occTuzs2FiTBbfPe968ZDaautFD4phLKf+IyFGfPZHV03a8vUVoE8daqtOkTDp1D7liyulHE6fFaNhJnfRChlALsTSk2+NCT40kPVnokLf4G2fIwpD3kryjUuUQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=1sNKBZu7; 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="1sNKBZu7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8A6AC4CEDD; Wed, 26 Feb 2025 01:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1740535185; bh=ASJ0DiR+O+GnD0uEDli+rpyWfGV2cfZuKIgW9a0X4Ko=; h=From:To:Cc:Subject:Date:Reply-to:From; b=1sNKBZu7CSHjuDlu7RhhvDbBth7IkAsed2bQX8TLVOjrHU0GJHP/ndkWY25wOsWh+ txZ6aqfnUFIwTrPPtr6XkQCb3tadOMSEvznSIKjRbeDLCkjTM9yi7DPY/vDpg6DEKP uRXwEZwOwI8wq7PFspmDq8aAvkTc87XkKbLO9IRk= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-49228: bpf: Fix a btf decl_tag bug when tagging a function Date: Wed, 26 Feb 2025 02:57:13 +0100 Message-ID: <2025022622-CVE-2022-49228-f915@gregkh> X-Mailer: git-send-email 2.48.1 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=4332; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=ASJ0DiR+O+GnD0uEDli+rpyWfGV2cfZuKIgW9a0X4Ko=; b=owGbwMvMwCRo6H6F97bub03G02pJDOn7SvxUWf577tbwsZm3cudZH46ERaunrFibd3F9pbH9k vSI404RHbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjAR80MMczjmFHOFeSWxTGqL LAy8tMjj2e1NOQzzTPdvX9F2yL5H+1eHUOMGtg++J+M2AQA= 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: Fix a btf decl_tag bug when tagging a function syzbot reported a btf decl_tag bug with stack trace below: general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] CPU: 0 PID: 3592 Comm: syz-executor914 Not tainted 5.16.0-syzkaller-11424-gb7892f7d5cb2 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:btf_type_vlen include/linux/btf.h:231 [inline] RIP: 0010:btf_decl_tag_resolve+0x83e/0xaa0 kernel/bpf/btf.c:3910 ... Call Trace: btf_resolve+0x251/0x1020 kernel/bpf/btf.c:4198 btf_check_all_types kernel/bpf/btf.c:4239 [inline] btf_parse_type_sec kernel/bpf/btf.c:4280 [inline] btf_parse kernel/bpf/btf.c:4513 [inline] btf_new_fd+0x19fe/0x2370 kernel/bpf/btf.c:6047 bpf_btf_load kernel/bpf/syscall.c:4039 [inline] __sys_bpf+0x1cbb/0x5970 kernel/bpf/syscall.c:4679 __do_sys_bpf kernel/bpf/syscall.c:4738 [inline] __se_sys_bpf kernel/bpf/syscall.c:4736 [inline] __x64_sys_bpf+0x75/0xb0 kernel/bpf/syscall.c:4736 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae The kasan error is triggered with an illegal BTF like below: type 0: void type 1: int type 2: decl_tag to func type 3 type 3: func to func_proto type 8 The total number of types is 4 and the type 3 is illegal since its func_proto type is out of range. Currently, the target type of decl_tag can be struct/union, var or func. Both struct/union and var implemented their own 'resolve' callback functions and hence handled properly in kernel. But func type doesn't have 'resolve' callback function. When btf_decl_tag_resolve() tries to check func type, it tries to get vlen of its func_proto type, which triggered the above kasan error. To fix the issue, btf_decl_tag_resolve() needs to do btf_func_check() before trying to accessing func_proto type. In the current implementation, func type is checked with btf_func_check() in the main checking function btf_check_all_types(). To fix the above kasan issue, let us implement 'resolve' callback func type properly. The 'resolve' callback will be also called in btf_check_all_types() for func types. The Linux kernel CVE team has assigned CVE-2022-49228 to this issue. Affected and fixed versions =========================== Issue introduced in 5.16 with commit b5ea834dde6b6e7f75e51d5f66dac8cd7c97b5ef and fixed in 5.16.19 with commit a3bcd2110c087bc62e90fddd4a93237b049d6e68 Issue introduced in 5.16 with commit b5ea834dde6b6e7f75e51d5f66dac8cd7c97b5ef and fixed in 5.17.2 with commit 796d5666f6422ddadc938fb888044fcc16f2dbe3 Issue introduced in 5.16 with commit b5ea834dde6b6e7f75e51d5f66dac8cd7c97b5ef and fixed in 5.18 with commit d7e7b42f4f956f2c68ad8cda87d750093dbba737 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-2022-49228 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/btf.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/a3bcd2110c087bc62e90fddd4a93237b049d6e68 https://git.kernel.org/stable/c/796d5666f6422ddadc938fb888044fcc16f2dbe3 https://git.kernel.org/stable/c/d7e7b42f4f956f2c68ad8cda87d750093dbba737