From mboxrd@z Thu Jan 1 00:00:00 1970 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 0AA80213E68 for ; Wed, 26 Feb 2025 02:13:40 +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=1740536020; cv=none; b=hv1iOiXW2o6MgDu8HZAWP+x9b2Qzd5Zb51EB+RyGlep2v7Q/SoDdB9ZZhKyfjbDH7JGDYtVRmtgdQubr0W4Ayj4y/qSAHCBNCRhTA8lrcbWj789rqeMh1dJAfDrw2+lxkd4IA0xMQGuQjvs77RJ0bQEppuYGDBoNM8BlVwwABMM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740536020; c=relaxed/simple; bh=1uinNvayQp46ycCrzEa6n3T5jwa1GF4lCFlsG6ZHj/I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=CcesW+UTPYXU5uuJVvFTAJKCs799o97t5kg1OA9+AvqpWSK+cRxd4RzH0twO19Nq4G/MZd+iM7UFls6W7/FSSoaeEOtBMUikjiSDrsgUWELt9X+0G5LzKnRB5aR291+PEbtmIj+RuF4NyPT5neroFuCSh4QmmgUUrzDeS6o7lqM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=l8s6W806; 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="l8s6W806" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7468C4CEDD; Wed, 26 Feb 2025 02:13:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1740536019; bh=1uinNvayQp46ycCrzEa6n3T5jwa1GF4lCFlsG6ZHj/I=; h=From:To:Cc:Subject:Date:Reply-to:From; b=l8s6W806v/oITbNQ2RgfKfkMX8plnw39bZI8MR6HKO4ZnUOvF8hGorS+NbcGNQJoD YNYQ9fSO8X0B3Kpm1CIrsGM8UbFqhKg0csKfZuifuEhiT/28dJXJ3+A98L6e/KGlg0 g5UJq7qiAybQ/s1ypP3CIBEo37cV8m9SgihQBqyc= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-49341: bpf, arm64: Clear prog->jited_len along prog->jited Date: Wed, 26 Feb 2025 03:10:15 +0100 Message-ID: <2025022641-CVE-2022-49341-b0e9@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=6059; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=1uinNvayQp46ycCrzEa6n3T5jwa1GF4lCFlsG6ZHj/I=; b=owGbwMvMwCRo6H6F97bub03G02pJDOn7yp9eXvMgRYJvsXWOxfZt8qY8Ac8N1Ha9v7uvsfCNP OvMhaJSHbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjCRxSwM80O52w/N3p/2+XeF 07HdtyZGy0nvWM+wYPN9cY5dDK6iv/fftXyXJPb5UPNZRgA= 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, arm64: Clear prog->jited_len along prog->jited syzbot reported an illegal copy_to_user() attempt from bpf_prog_get_info_by_fd() [1] There was no repro yet on this bug, but I think that commit 0aef499f3172 ("mm/usercopy: Detect vmalloc overruns") is exposing a prior bug in bpf arm64. bpf_prog_get_info_by_fd() looks at prog->jited_len to determine if the JIT image can be copied out to user space. My theory is that syzbot managed to get a prog where prog->jited_len has been set to 43, while prog->bpf_func has ben cleared. It is not clear why copy_to_user(uinsns, NULL, ulen) is triggering this particular warning. I thought find_vma_area(NULL) would not find a vm_struct. As we do not hold vmap_area_lock spinlock, it might be possible that the found vm_struct was garbage. [1] usercopy: Kernel memory exposure attempt detected from vmalloc (offset 792633534417210172, size 43)! kernel BUG at mm/usercopy.c:101! Internal error: Oops - BUG: 0 [#1] PREEMPT SMP Modules linked in: CPU: 0 PID: 25002 Comm: syz-executor.1 Not tainted 5.18.0-syzkaller-10139-g8291eaafed36 #0 Hardware name: linux,dummy-virt (DT) pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : usercopy_abort+0x90/0x94 mm/usercopy.c:101 lr : usercopy_abort+0x90/0x94 mm/usercopy.c:89 sp : ffff80000b773a20 x29: ffff80000b773a30 x28: faff80000b745000 x27: ffff80000b773b48 x26: 0000000000000000 x25: 000000000000002b x24: 0000000000000000 x23: 00000000000000e0 x22: ffff80000b75db67 x21: 0000000000000001 x20: 000000000000002b x19: ffff80000b75db3c x18: 00000000fffffffd x17: 2820636f6c6c616d x16: 76206d6f72662064 x15: 6574636574656420 x14: 74706d6574746120 x13: 2129333420657a69 x12: 73202c3237313031 x11: 3237313434333533 x10: 3336323937207465 x9 : 657275736f707865 x8 : ffff80000a30c550 x7 : ffff80000b773830 x6 : ffff80000b773830 x5 : 0000000000000000 x4 : ffff00007fbbaa10 x3 : 0000000000000000 x2 : 0000000000000000 x1 : f7ff000028fc0000 x0 : 0000000000000064 Call trace: usercopy_abort+0x90/0x94 mm/usercopy.c:89 check_heap_object mm/usercopy.c:186 [inline] __check_object_size mm/usercopy.c:252 [inline] __check_object_size+0x198/0x36c mm/usercopy.c:214 check_object_size include/linux/thread_info.h:199 [inline] check_copy_size include/linux/thread_info.h:235 [inline] copy_to_user include/linux/uaccess.h:159 [inline] bpf_prog_get_info_by_fd.isra.0+0xf14/0xfdc kernel/bpf/syscall.c:3993 bpf_obj_get_info_by_fd+0x12c/0x510 kernel/bpf/syscall.c:4253 __sys_bpf+0x900/0x2150 kernel/bpf/syscall.c:4956 __do_sys_bpf kernel/bpf/syscall.c:5021 [inline] __se_sys_bpf kernel/bpf/syscall.c:5019 [inline] __arm64_sys_bpf+0x28/0x40 kernel/bpf/syscall.c:5019 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x48/0x114 arch/arm64/kernel/syscall.c:52 el0_svc_common.constprop.0+0x44/0xec arch/arm64/kernel/syscall.c:142 do_el0_svc+0xa0/0xc0 arch/arm64/kernel/syscall.c:206 el0_svc+0x44/0xb0 arch/arm64/kernel/entry-common.c:624 el0t_64_sync_handler+0x1ac/0x1b0 arch/arm64/kernel/entry-common.c:642 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:581 Code: aa0003e3 d00038c0 91248000 97fff65f (d4210000) The Linux kernel CVE team has assigned CVE-2022-49341 to this issue. Affected and fixed versions =========================== Issue introduced in 4.16 with commit db496944fdaaf2a67d2f60529f5dc23abf809506 and fixed in 4.19.247 with commit aaf61a312af63e1cfe2264c4c5b8cd4ea3626025 Issue introduced in 4.16 with commit db496944fdaaf2a67d2f60529f5dc23abf809506 and fixed in 5.4.198 with commit e412b3d178ea4bf746f6b8ee086761613704c6be Issue introduced in 4.16 with commit db496944fdaaf2a67d2f60529f5dc23abf809506 and fixed in 5.10.122 with commit 0cf7aaff290cdc4d7cee683d4a18138b0dacac48 Issue introduced in 4.16 with commit db496944fdaaf2a67d2f60529f5dc23abf809506 and fixed in 5.15.47 with commit 3f4d5e727aeaa610688d46c9f101f78b7f712583 Issue introduced in 4.16 with commit db496944fdaaf2a67d2f60529f5dc23abf809506 and fixed in 5.17.15 with commit 5c25a3040bc0486c41a7b63a1fb0de7cdb846ad7 Issue introduced in 4.16 with commit db496944fdaaf2a67d2f60529f5dc23abf809506 and fixed in 5.18.4 with commit 41f7c4f85d402043687e863627a1a84fa867c62d Issue introduced in 4.16 with commit db496944fdaaf2a67d2f60529f5dc23abf809506 and fixed in 5.19 with commit 10f3b29c65bb2fe0d47c2945cd0b4087be1c5218 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-49341 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: arch/arm64/net/bpf_jit_comp.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/aaf61a312af63e1cfe2264c4c5b8cd4ea3626025 https://git.kernel.org/stable/c/e412b3d178ea4bf746f6b8ee086761613704c6be https://git.kernel.org/stable/c/0cf7aaff290cdc4d7cee683d4a18138b0dacac48 https://git.kernel.org/stable/c/3f4d5e727aeaa610688d46c9f101f78b7f712583 https://git.kernel.org/stable/c/5c25a3040bc0486c41a7b63a1fb0de7cdb846ad7 https://git.kernel.org/stable/c/41f7c4f85d402043687e863627a1a84fa867c62d https://git.kernel.org/stable/c/10f3b29c65bb2fe0d47c2945cd0b4087be1c5218