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 C8C94215F4B for ; Wed, 26 Feb 2025 02:00:22 +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=1740535222; cv=none; b=k+hOSj87hZoYR3wKc3FgprK0vx9BRkq7X7C6M0iSOtDxRBhYZdY9tdG67MZO3emq908coauLHearPrKd0yXhgPaSnV7SKjMqcJDgh8sRocDLTJum1vJBhReIg6vCL2Z+IlgYjFNNgUw3eItWbR7ud70LylytOEQP61OhVUWB59o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740535222; c=relaxed/simple; bh=Z4ub/GcNUtzHTHb0ANLCcWZyz9sOuEvvKt8I9pPgkn4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=eAO5FfMiX/zoAJ1cVBEmXdcAUu2byrIFHhzEo9pfVKVGXT4BIiCIyAvZKtq3LYoBeCK+gqCC4AOn0yw+KpWIOrJNBPaNFc2AY2OiU3d9FKK5h4ubQuN2naHIl8C112M4qQo6VgHLD0Q+fwFTV7UTksPBW/pvRqS+Xa66XfWdf+0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=KC0/Pi3V; 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="KC0/Pi3V" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37A48C4CEE7; Wed, 26 Feb 2025 02:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1740535222; bh=Z4ub/GcNUtzHTHb0ANLCcWZyz9sOuEvvKt8I9pPgkn4=; h=From:To:Cc:Subject:Date:Reply-to:From; b=KC0/Pi3VMC4iy/OPGB0IJbphhGcHeT64Z1E7NG5BsgVVRB53dpKOBN4OiswR70zHb dle5vgL0ghuN86a/FR2nzm3f6oGe7XiG0m4bzsKjuog8vjjpO0QJygCf2luAcOYYNb x+Xz28GgQ6c7PZVkIe2P5rU5EADsUjeuR6dcVvXs= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-49276: jffs2: fix memory leak in jffs2_scan_medium Date: Wed, 26 Feb 2025 02:58:01 +0100 Message-ID: <2025022631-CVE-2022-49276-d58d@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=6410; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=Z4ub/GcNUtzHTHb0ANLCcWZyz9sOuEvvKt8I9pPgkn4=; b=owGbwMvMwCRo6H6F97bub03G02pJDOn7SsJVLBPqg7Y9yI+wrX/queE/L0fh8Zv3J/GW7jyvk LqE5dPWjlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZjIGi6GBcss1NgLrBa+NO12 rV3/ysbFPs9RnGHBUrbLPzbF3YjP3x1Wt0534iQ1dYnNAA== 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: jffs2: fix memory leak in jffs2_scan_medium If an error is returned in jffs2_scan_eraseblock() and some memory has been added to the jffs2_summary *s, we can observe the following kmemleak report: -------------------------------------------- unreferenced object 0xffff88812b889c40 (size 64): comm "mount", pid 692, jiffies 4294838325 (age 34.288s) hex dump (first 32 bytes): 40 48 b5 14 81 88 ff ff 01 e0 31 00 00 00 50 00 @H........1...P. 00 00 01 00 00 00 01 00 00 00 02 00 00 00 09 08 ................ backtrace: [] __kmalloc+0x613/0x910 [] jffs2_sum_add_dirent_mem+0x5c/0xa0 [] jffs2_scan_medium.cold+0x36e5/0x4794 [] jffs2_do_mount_fs.cold+0xa7/0x2267 [] jffs2_do_fill_super+0x383/0xc30 [] jffs2_fill_super+0x2ea/0x4c0 [] mtd_get_sb+0x254/0x400 [] mtd_get_sb_by_nr+0x4f/0xd0 [] get_tree_mtd+0x498/0x840 [] jffs2_get_tree+0x25/0x30 [] vfs_get_tree+0x8d/0x2e0 [] path_mount+0x50f/0x1e50 [] do_mount+0x107/0x130 [] __se_sys_mount+0x1c5/0x2f0 [] __x64_sys_mount+0xc7/0x160 [] do_syscall_64+0x45/0x70 unreferenced object 0xffff888114b54840 (size 32): comm "mount", pid 692, jiffies 4294838325 (age 34.288s) hex dump (first 32 bytes): c0 75 b5 14 81 88 ff ff 02 e0 02 00 00 00 02 00 .u.............. 00 00 84 00 00 00 44 00 00 00 6b 6b 6b 6b 6b a5 ......D...kkkkk. backtrace: [] kmem_cache_alloc_trace+0x584/0x880 [] jffs2_sum_add_inode_mem+0x54/0x90 [] jffs2_scan_medium.cold+0x4481/0x4794 [...] unreferenced object 0xffff888114b57280 (size 32): comm "mount", pid 692, jiffies 4294838393 (age 34.357s) hex dump (first 32 bytes): 10 d5 6c 11 81 88 ff ff 08 e0 05 00 00 00 01 00 ..l............. 00 00 38 02 00 00 28 00 00 00 6b 6b 6b 6b 6b a5 ..8...(...kkkkk. backtrace: [] kmem_cache_alloc_trace+0x584/0x880 [] jffs2_sum_add_xattr_mem+0x54/0x90 [] jffs2_scan_medium.cold+0x298c/0x4794 [...] unreferenced object 0xffff8881116cd510 (size 16): comm "mount", pid 692, jiffies 4294838395 (age 34.355s) hex dump (first 16 bytes): 00 00 00 00 00 00 00 00 09 e0 60 02 00 00 6b a5 ..........`...k. backtrace: [] kmem_cache_alloc_trace+0x584/0x880 [] jffs2_sum_add_xref_mem+0x54/0x90 [] jffs2_scan_medium.cold+0x3a20/0x4794 [...] -------------------------------------------- Therefore, we should call jffs2_sum_reset_collected(s) on exit to release the memory added in s. In addition, a new tag "out_buf" is added to prevent the NULL pointer reference caused by s being NULL. (thanks to Zhang Yi for this analysis) The Linux kernel CVE team has assigned CVE-2022-49276 to this issue. Affected and fixed versions =========================== Issue introduced in 2.6.15 with commit e631ddba588783edd521c5a89f7b2902772fb691 and fixed in 4.9.311 with commit 9b0c69182f09b70779817af4dcf89780955d5c4c Issue introduced in 2.6.15 with commit e631ddba588783edd521c5a89f7b2902772fb691 and fixed in 4.14.276 with commit b36bccb04e14cc0c1e2d0e92d477fe220314fad6 Issue introduced in 2.6.15 with commit e631ddba588783edd521c5a89f7b2902772fb691 and fixed in 4.19.238 with commit e711913463af916d777a4873068f415f1fe2ad33 Issue introduced in 2.6.15 with commit e631ddba588783edd521c5a89f7b2902772fb691 and fixed in 5.4.189 with commit 455f4a23490bfcbedc8e5c245c463a59b19e5ddd Issue introduced in 2.6.15 with commit e631ddba588783edd521c5a89f7b2902772fb691 and fixed in 5.10.110 with commit 51dbb5e36d59f62e34d462b801c1068248149cfe Issue introduced in 2.6.15 with commit e631ddba588783edd521c5a89f7b2902772fb691 and fixed in 5.15.33 with commit 52ba0ab4f0a606f02a6163493378989faa1ec10a Issue introduced in 2.6.15 with commit e631ddba588783edd521c5a89f7b2902772fb691 and fixed in 5.16.19 with commit b26bbc0c122cad038831f226a4cb4de702225e16 Issue introduced in 2.6.15 with commit e631ddba588783edd521c5a89f7b2902772fb691 and fixed in 5.17.2 with commit 82462324bf35b6b553400af1c1aa265069cee28f Issue introduced in 2.6.15 with commit e631ddba588783edd521c5a89f7b2902772fb691 and fixed in 5.18 with commit 9cdd3128874f5fe759e2c4e1360ab7fb96a8d1df 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-49276 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: fs/jffs2/scan.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/9b0c69182f09b70779817af4dcf89780955d5c4c https://git.kernel.org/stable/c/b36bccb04e14cc0c1e2d0e92d477fe220314fad6 https://git.kernel.org/stable/c/e711913463af916d777a4873068f415f1fe2ad33 https://git.kernel.org/stable/c/455f4a23490bfcbedc8e5c245c463a59b19e5ddd https://git.kernel.org/stable/c/51dbb5e36d59f62e34d462b801c1068248149cfe https://git.kernel.org/stable/c/52ba0ab4f0a606f02a6163493378989faa1ec10a https://git.kernel.org/stable/c/b26bbc0c122cad038831f226a4cb4de702225e16 https://git.kernel.org/stable/c/82462324bf35b6b553400af1c1aa265069cee28f https://git.kernel.org/stable/c/9cdd3128874f5fe759e2c4e1360ab7fb96a8d1df