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 B884A1F8907 for ; Mon, 21 Oct 2024 18:04:31 +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=1729533871; cv=none; b=SfSBnPKwtKqL5SpG/rS5mwIZLMjTci90WGvj4ALXco09fh2GbJTx6H589TD9KXahFh4qlEwCO4KeQV/W6DUVsjfhR+L3XgxSlI5vjzMMvZCfeU8OxvbXNKqY93r1zggxUNfkWviZSxmKJwvHwrE1O9ZaMVw2DJu7zm3Lg2UMzMA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729533871; c=relaxed/simple; bh=dWMQUuvV6QOTyjZ9mgpB2cY8kIH5XowNvScw+MZHnDo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=bleat9Qf/Etatg4OiZPXH+CwKEUPjo+5LMuZscATTTWLdPViZhTjEjT65ND27NUCXdUxqqg6zP+p540lRw6nl7N5zdJtefezXo/M8JcFOkDnsxZXd7tF+l/6u3SvcI/2Z/+wwjjjEb/giiD+cjEbPIahEyEUdKlHsQ0bFJYTynE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=iypzVsSx; 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="iypzVsSx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE854C4CEC7; Mon, 21 Oct 2024 18:04:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1729533871; bh=dWMQUuvV6QOTyjZ9mgpB2cY8kIH5XowNvScw+MZHnDo=; h=From:To:Cc:Subject:Date:Reply-to:From; b=iypzVsSxXsZiO5DWiCspSiZfnjAj7WWlrkNewEe6yzHam7Mgpg5dABIpPKSKxMHB0 QfRSSfBMviMjwIxbHbMPesGuUynxqEqnw9UrH8MSQ5nlrOrHDJd5ZChFTCODMTlkdQ 8HciMLoGEloCMR9OmRequsOjqCKfdLYKoTn0huSM= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-49880: ext4: fix off by one issue in alloc_flex_gd() Date: Mon, 21 Oct 2024 20:01:28 +0200 Message-ID: <2024102116-CVE-2024-49880-11cd@gregkh> X-Mailer: git-send-email 2.47.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=3648; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=dWMQUuvV6QOTyjZ9mgpB2cY8kIH5XowNvScw+MZHnDo=; b=owGbwMvMwCRo6H6F97bub03G02pJDOli096UxbLXJfkvqVqzOcVN56TTIue1x+p9Fi4WXPntB XeGp4heRywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAEyk4QLDPI2DhapX4nYtyayL dfy32f6k69k1Hxnmp9fM9Jef3/hu4WY56fZMBv4a5qh6AA== 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: ext4: fix off by one issue in alloc_flex_gd() Wesley reported an issue: ================================================================== EXT4-fs (dm-5): resizing filesystem from 7168 to 786432 blocks ------------[ cut here ]------------ kernel BUG at fs/ext4/resize.c:324! CPU: 9 UID: 0 PID: 3576 Comm: resize2fs Not tainted 6.11.0+ #27 RIP: 0010:ext4_resize_fs+0x1212/0x12d0 Call Trace: __ext4_ioctl+0x4e0/0x1800 ext4_ioctl+0x12/0x20 __x64_sys_ioctl+0x99/0xd0 x64_sys_call+0x1206/0x20d0 do_syscall_64+0x72/0x110 entry_SYSCALL_64_after_hwframe+0x76/0x7e ================================================================== While reviewing the patch, Honza found that when adjusting resize_bg in alloc_flex_gd(), it was possible for flex_gd->resize_bg to be bigger than flexbg_size. The reproduction of the problem requires the following: o_group = flexbg_size * 2 * n; o_size = (o_group + 1) * group_size; n_group: [o_group + flexbg_size, o_group + flexbg_size * 2) o_size = (n_group + 1) * group_size; Take n=0,flexbg_size=16 as an example: last:15 |o---------------|--------------n-| o_group:0 resize to n_group:30 The corresponding reproducer is: img=test.img rm -f $img truncate -s 600M $img mkfs.ext4 -F $img -b 1024 -G 16 8M dev=`losetup -f --show $img` mkdir -p /tmp/test mount $dev /tmp/test resize2fs $dev 248M Delete the problematic plus 1 to fix the issue, and add a WARN_ON_ONCE() to prevent the issue from happening again. [ Note: another reproucer which this commit fixes is: img=test.img rm -f $img truncate -s 25MiB $img mkfs.ext4 -b 4096 -E nodiscard,lazy_itable_init=0,lazy_journal_init=0 $img truncate -s 3GiB $img dev=`losetup -f --show $img` mkdir -p /tmp/test mount $dev /tmp/test resize2fs $dev 3G umount $dev losetup -d $dev -- TYT ] The Linux kernel CVE team has assigned CVE-2024-49880 to this issue. Affected and fixed versions =========================== Issue introduced in 6.8 with commit 665d3e0af4d3 and fixed in 6.10.14 with commit 0d80d2b8bf61 Issue introduced in 6.8 with commit 665d3e0af4d3 and fixed in 6.11.3 with commit acb559d68261 Issue introduced in 6.8 with commit 665d3e0af4d3 and fixed in 6.12-rc2 with commit 6121258c2b33 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-49880 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/ext4/resize.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/0d80d2b8bf613398baf7185009e35f9d0459ecb0 https://git.kernel.org/stable/c/acb559d6826116cc113598640d105094620c2526 https://git.kernel.org/stable/c/6121258c2b33ceac3d21f6a221452692c465df88