From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796326415; b=eFQfyDaPeQeKDKdlaQ4q+Zj14hl3vyBVwDTzQCZg/ywJTIF+CZhjxbSEoCviPGTk/2fR ahmIpIxfQqTJbZTFmoujQAYxqrA0M304hOTFszY0q4fJ96fUbXq7hFH61ZlHT4Dft4Z7x WODQhyIjCLVpNYGN5ap4E7037NK9hQNg7kS5/FOM6+9AiG2v2ae8AmtX/tct3uSWeYArV UhicsdHXhPP/QrzqRm1bDzCGcP0/0GNnDK8Z9D9nJBgVewT/BZRZZyqc8V1Bh/rAYoVji Iq5rjj9LzeQ+RWjgMB2LN8DUz3twzyH468b9xo1OmQLWfUDc914ns9DeInYOjErM9cg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796326415; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=+R5Oxln5yB9u78XpnuS6MQaIAMXLb83Czf6dPIDHiaU=; b=wFD9pKahZRxL/QDsEbydW25yGIqQIotQQtdDTmDRsMjgWI/kl5cwoi9ZwXgdLdUmJxgq tc3ynz2QXNRfy+N42fOFQFQ7QZ+SPz+uJY0HWITMMsAhEGAez5E2M8fFOGcjJRRRCttiB N5ro1d5Ipt+Mwoiy1M6M+jL8eMA7JQc0cjt9Es/wmwddpL8fjOqYtCtFMgrgozvHyy7t3 eZfJ5qFFoBF4XivTct3/+Syf2K+1nTWX4o6DGtXGOBk65TqRi5G/kmeLDcbQunOJLmP4Q uhajOBRQyjyq9BV539LczXk4Jse6xnCgpcHbBl5t2YrnAvJ3WxmWyk5k9QeF8M6gRlQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JpfYC4E2; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 390B0606A322 for ; Thu, 3 Dec 2026 19:33:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JpfYC4E2 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 441381F00931; Thu, 3 Dec 2026 19:33:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796326415; bh=+R5Oxln5yB9u78XpnuS6MQaIAMXLb83Czf6dPIDHiaU=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=JpfYC4E2HlaVqe9KAoGy6kRDTt9daa0DFMMUTcRS86H63cVPnJKmAuNlPBsM/8hc5 ZqS/hQ3LXnDtkoS8FUi7ZWnYnT3Je3BnpIjZ2I5bPZryF2qGNIjx4N/1PrdcK1ZqPy WJdbSi5l5MfhTMKFW4KK7kMapqeSiHdugCKcxUqoJKxZNQ65kV+Q8IElXTYqM/4E9D sXYdi/kUadSnIwtlfqOCgN4cTCcdmYUGOgb4WDxYvKHOk4E3/MevgF0L4XbOSThkiv SbGi3d04jNnQRBBbozucDW1Vb3CRzd5lL4cIJziIv9cD4loC/v36/wWHjNBtnqB6NM w51A1gcjCpibA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v15 03/13] ext4: replace ext4_dir_entry with ext4_dir_entry_2 Reply-To: sashiko-reviews@lists.linux.dev To: "Artem Blagodarenko" , linux-ext4@vger.kernel.org Cc: tytso@mit.edu In-Reply-To: <20261203184938.422849-4-ablagodarenko@thelustrecollective.com> References: <20261203184938.422849-1-ablagodarenko@thelustrecollective.com> <20261203184938.422849-4-ablagodarenko@thelustrecollective.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 19:33:34 +0000 X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] ext4: EXT4_BASE_DIR_LEN change exposes OOB read in is_fake_dir_entry() - [Low] ext4: commit message omits EXT4_BASE_DIR_LEN change and misstates rationale -- commit 905a73de84c1289ce2b9fc43573bee81e7c8e5f8 Author: Artem Blagodarenko > ext4: replace ext4_dir_entry with ext4_dir_entry_2 > > Replace remaining uses of struct ext4_dir_entry in namei.c > with struct ext4_dir_entry_2. > > The code paths affected by this change already depend on the > filetype feature, so using struct ext4_dir_entry_2 is > appropriate and avoids mixing the two directory entry types > unnecessarily. > > This change does not affect support for 16-bit rec_len. > > Signed-off-by: Artem Blagodarenko > Reviewed-by: Andreas Dilger [Severity: Low] Does this commit message accurately cover the changes and rationale? The patch also changes EXT4_BASE_DIR_LEN in fs/ext4/ext4.h from 9 to 8, which alters the loop bound in ext4_search_dir() and is unrelated to replacing struct ext4_dir_entry. If split out, that change would fix commit c186f0887fe7 ("ext4: fix use-after-free in ext4_search_dir"). The changelog also omits the count_offset =3D sizeof(struct dx_node) cleanup in get_dx_countlimit() and the KUnit updates in fs/ext4/namei.h and fs/ext4/namei-test.c. The converted functions in fs/ext4/namei.c run regardless of whether EXT4_FEATURE_INCOMPAT_FILETYPE is set; the rename is safe because both structs share the same inode and rec_len layout and none of these paths access name_len or file_type. Both structs also have the same __le16 rec_len field, so it is 16-bit name_len rather than rec_len that differs between them. > diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h > index dc2c181337a16..ca727888425ab 100644 > --- a/fs/ext4/ext4.h > +++ b/fs/ext4/ext4.h > @@ -2523,10 +2523,8 @@ static inline int ext4_emergency_state(struct supe= r_block *sb) > * Structure of a directory entry > */ > #define EXT4_NAME_LEN 255 > -/* > - * Base length of the ext4 directory entry excluding the name length > - */ > -#define EXT4_BASE_DIR_LEN (sizeof(struct ext4_dir_entry_2) - EXT4_NAME_L= EN) > +/* offsetof avoids sizeof()+padding giving 9 instead of the correct on-d= isk 8 */ > +#define EXT4_BASE_DIR_LEN offsetof(struct ext4_dir_entry_2, name) [Severity: Medium] Can lowering EXT4_BASE_DIR_LEN from 9 to 8 cause a 1-byte out-of-bounds read of de->name[1] in is_fake_dir_entry()? Previously, EXT4_BASE_DIR_LEN was 9 due to trailing struct padding, so ext4_search_dir() stopped at (char *)de < dlimit - 9 and kept de->name[1] in bounds. With EXT4_BASE_DIR_LEN now 8, a corrupted directory block with an unaligned rec_len can place an entry at dlimit - 9 with name_len =3D=3D = 1. Fast-commit replay (ext4_fc_replay_unlink() -> __ext4_unlink() -> ext4_find_entry()) can look up a 1-byte "." entry from EXT4_FC_TAG_UNLINK, pass de->name + de->name_len <=3D dlimit in ext4_search_dir(), and reach __ext4_check_dir_entry(), which calls is_fake_dir_entry(de) first: fs/ext4/dir.c:is_fake_dir_entry() { if ((de->name_len > 0) && (de->name_len <=3D 2) && (de->name[0] =3D=3D '.'= ) && (de->name[1] =3D=3D '.' || de->name[1] =3D=3D '\0')) return true; } When de sits at dlimit - 9 with name_len =3D=3D 1 and name[0] =3D=3D '.', de->name[1] reads at dlimit, one byte past the directory block buffer, triggering a KASAN out-of-bounds report or a page fault. Handling name_len =3D=3D 1 without reading de->name[1] avoids the out-of-bounds read. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203184938.4228= 49-1-ablagodarenko@thelustrecollective.com?part=3D3