Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A3F87C021AA for ; Fri, 21 Feb 2025 09:03:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tlOwX-00064G-CD; Fri, 21 Feb 2025 04:03:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tlOwU-00063g-8N for grub-devel@gnu.org; Fri, 21 Feb 2025 04:03:31 -0500 Received: from mx.mylinuxtime.de ([46.4.70.188]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tlOwR-0004Jx-Uz for grub-devel@gnu.org; Fri, 21 Feb 2025 04:03:29 -0500 Received: from leda.eworm.net (p5085a8ac.dip0.t-ipconnect.de [80.133.168.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx.mylinuxtime.de (Postfix) with ESMTPSA id 3E7A8255D3A; Fri, 21 Feb 2025 10:02:55 +0100 (CET) Authentication-Results: mx.mylinuxtime.de; auth=pass smtp.auth=mail@eworm.de smtp.mailfrom=list@eworm.de Date: Fri, 21 Feb 2025 10:02:54 +0100 From: Christian Hesse To: Michael Chang via Grub-devel Cc: Michael Chang Subject: Re: [PATCH] fs/ext2: Rework out-of-bounds read for inline and external extents Message-ID: <20250221100254.03f2e337@leda.eworm.net> In-Reply-To: <20250221010613.1179224-1-mchang@suse.com> References: <20250221010613.1179224-1-mchang@suse.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.48; x86_64-pc-linux-gnu) X-Face: %O:rCSkHSKf7^4uF|FD$9$I0}g$nbnS1{DYPvs#:,~e`).mzj\$P9]V!WCveE/XdbL,L!{)6v%x4\Bt!b#{; dS&h"7l=ow'^({02!2%XOugod|u*mYBVm-OS:VpZ"ZrRA4[Q&zye,^j; ftj!Hxx\1@; LM)Pz)|B%1#sfF; s; ,N?*K*^) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUZFRFENy6KVTKEd23CiGHeqofJvrX4+vdHgItOAAAACXBIWXMAAA3XAAAN1wFCKJt4AAACUklEQVQ4y2VUTZeqMAxNxXG2Io5uGd64L35unbF9ax0b3OLxgFs4PcLff0lBHeb1QIq5uelNCEJNq/TIFGyeC+iugH0WJr+B1MvzWASpuP4CYHOB0VfoDdddwA7OIFQIEHjXDiCtV5e9QX0WMu8AG0mB7g7WP4GqeqVdsi4vv/5kFBvaF/zD7zDquL4DxbrDGDyAsgNYOsJOYzth4Q9ZF6iLV+6TLAT1pi2kuvgAtZxSjoG8cL+8vIn251uoe1OOEWwbIPU04gHsmMsoxyyhYsD2FdIigF1yxaVbBuSOCAlCoX324I7wNMhrO1bhOLsRoA6DC6wQ5eQiSG5BiWQfM4gN+uItQTRDMaJUhVbGyKWCuaaUGSVFVKpl4PdoDn3yY8J+YxQxyhlHfoYOyPgyDcO+cSQK6Bvabjcy2nwRo3pxgA8jslnCuYw23ESOzHAPYwo4ITNQMaOO+RGPEGhSlPEZBh2jmBEjQ5cKbxmr0ruAe/WCriUxW76I8T3h7vqY5VR5wXLdERodg2rHEzdxxk5KpXTL4FwnarvndKM5/MWDY5CuBBdQ+3/0ivsUJHicuHd+Xh3jOdBL+FjSGq4SPCwco+orpWlERRTNo7BHCvbNXFVSIQMp+P5QsIL9upmr8kMTUOfxEHoanwzKRcNAe76WbjBwex/RkdHu48xT5YqP70DaMOhBcTHmAVDxLaBdle93oJy1QKFUh2GXT4am+YH/GGel1CeI98GdMXsytjCKIq/9cMrlgxFCROv+3/BU1fijNpcVD6DxE8VfLBaxUGr1D5usgDYdjwiPAAAAAElFTkSuQmCC MIME-Version: 1.0 X-Rspamd-Server: mx X-Rspamd-Queue-Id: 3E7A8255D3A X-Spamd-Bar: / X-Stat-Signature: 1xtuh8uk6zxaxskbtqgfae77uzfdw1fb X-Rspamd-Action: no action X-Spamd-Result: default: False [0.00 / 15.00] Received-SPF: pass client-ip=46.4.70.188; envelope-from=list@eworm.de; helo=mx.mylinuxtime.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The development of GNU GRUB Content-Type: multipart/mixed; boundary="===============7975599716199468299==" Errors-To: grub-devel-bounces+grub-devel=archiver.kernel.org@gnu.org Sender: grub-devel-bounces+grub-devel=archiver.kernel.org@gnu.org --===============7975599716199468299== Content-Type: multipart/signed; boundary="Sig_/TF7S9qnmYQqm6_lcNOeiy=S"; protocol="application/pgp-signature"; micalg=pgp-sha256 --Sig_/TF7S9qnmYQqm6_lcNOeiy=S Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Michael Chang via Grub-devel on Fri, 2025/02/21 09:06: > Previously, the number of extent entries was not properly capped based > on the actual available space. This could lead to insufficient reads for > external extents, since the computation was based solely on the inline > extent layout. >=20 > In this patch, when processing the extent header, we determine whether > the header is stored inline (i.e., at inode->blocks.dir_blocks) or in an > external extent block. We then clamp the number of entries accordingly > (using max_inline_ext for inline extents and max_external_ext for > external extent blocks). >=20 > This change ensures that only the valid number of extent entries is > processed, preventing out-of-bound reads and potential filesystem > corruption. >=20 > Fixes: 7e2f750f0a (fs/ext2: Fix out-of-bounds read for inline extents) >=20 > Signed-off-by: Michael Chang Tested and it fixes reading from loopback disk on ext4 for me. Thanks! Tested-by: Christian Hesse --=20 main(a){char*c=3D/* Schoene Gruesse */"B?IJj;MEH" "CX:;",b;for(a/* Best regards my address: */=3D0;b=3Dc[a+= +];) putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);} --Sig_/TF7S9qnmYQqm6_lcNOeiy=S Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEXHmveYAHrRp+prOviUUh18yA9HYFAme4QT4ACgkQiUUh18yA 9HaD9ggAxHwu9O4sYD7l+wnOuJLnayMmCr/ZG3TPyZ3GqZKW2mjAX41f1bMwiLrE KzEquvYYv+sMcNVlvhWr0sRe4bLNW2ICq15600mXHoasOG2OVumOUg03Mh3JTNSp lswKnDZgulFQWqdK5SwJL3hPb5A6Ue1M5xwXo1jobufSfFoaKBkhgRJp7CKjzVQY sidTkXNHjup/qOwoZHnCxLAl+rlX9Wp1IaXoxs+dlpLD+bn+uVpqika6lrEtyDpR fdg7U107HdhwFxVB+ljzjcowXA3iubLaSDTR/hOzqNtXqc+AIqFJpTuK0SPMGRqU ISg5r1bPbxRtG6I7idJ8ZZOWUe5Q+w== =7Lpi -----END PGP SIGNATURE----- --Sig_/TF7S9qnmYQqm6_lcNOeiy=S-- --===============7975599716199468299== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KR3J1Yi1kZXZl bCBtYWlsaW5nIGxpc3QKR3J1Yi1kZXZlbEBnbnUub3JnCmh0dHBzOi8vbGlzdHMuZ251Lm9yZy9t YWlsbWFuL2xpc3RpbmZvL2dydWItZGV2ZWwK --===============7975599716199468299==--