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=1796460062; b=fdGeyAFSk3cRtxhYHrAwLhrOec9dcH2U/8nsOnPIWjjHleqDzakJu41bZunmc2garNJX lxJognmgx3WvSIOTO668N5tjgON4mp9thbQ7JbbjtVBgU61uLb+yFjOKVlkwObhCUvrQt QEJ4KQ4b96japEVyAJkzfPydHBI4qMQiXySz1PFtMMSWO+AytmIsZZC0bd3gvaaL7kWf7 hnY3SuzEHh6yefgGQyRzVHeKPEEvJXL2DbNZqWrLzc67mJeKQBMtbAUIDVNMisYjnZDnP 0OtIO1xnCb1YAdsHl0evr9USEG6duSKrVPK/0wM+JPSLTy+9lKWVBG4cXxV2Xsv6aMw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796460062; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=2z7lE5+oGPexrrfJAX247f5uLuiUIGhwhUzZI53Z3Ps=; b=DknTIgPVVeF8JnBpQs1goYX2Za/Kaldj1F915V0/eNGPggoaU9L98jaRf9IpRpSw5hVu R0wXlQXWYTYKABdTNf7lIlXgbz0RHdGs66c/8fGNwsfCx2+Yvgh/ybG4iUuV6sMEv3rbV p+7zx7c2KPhk3V6bjOwzKrJ8UkUWykclErnejFyVlibfdz7AhISdilm519N7EvKjG0nRU PWjgsOf4PP1UNyCggBa8nX/S6x6qLSRn2RAfOw+pW3a/Zgr5ZQ45ElQRjuifFFsYjsEwv fP8hnEvPyqP0BLSEOh5k2zJJN0hM+hLieFdiw09zfrRrNRw/nO3oCbf84DFg4ZxDNuQ== 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=ccoM8enV; 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)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E460606A322 for ; Sat, 5 Dec 2026 08:41:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ccoM8enV Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC72F1F0092B; Sat, 5 Dec 2026 08:41:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796460062; bh=2z7lE5+oGPexrrfJAX247f5uLuiUIGhwhUzZI53Z3Ps=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=ccoM8enVmvK8FgnEw/p/879x8B2UReZWOo5z1S4dbBrYmXAP+F1JW1KW+IEfERpDJ 8AExWuHUkgZI5X1dpwzA/K9tNGaRtVnSCsUudeg7STm03wU6RHX9pH/jCNU8c//1rb EVuUtrUBhpgCpLy7ZcucezKgJSY//JWUDKV50JfS63DbTZBvPDLY72XKC2ldcjGTNa 5w++nT4B+e8FEU6FV/6dKrXMMbtmqfPwNNed3QJkFu7lazil3kDwfFFjg9JDSzYai+ PfNJkEtgcA+2r8MS18dCYxSGL3lriDGK/TKDXxvM38zvtNl60+vxw8iBk/9gG8Ledy 8IGIj0A5bgj9g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] ext4: validate dot entry before reading dotdot in htree readdir Reply-To: sashiko-reviews@lists.linux.dev To: "Kyuwon Cho" Cc: linux-ext4@vger.kernel.org, tytso@mit.edu In-Reply-To: <179637501338.1425433.8835682775805888953@gmail.com> References: <179637501338.1425433.8835682775805888953@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 08:41:01 +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 1 potential issue to consider: - [Low] ext4: duplicated root hash guard and rec_len read in ext4_htree_fill_tree() -- commit 3e82da14fda178af29c9f8c2f58b8aac85ce06cf Author: Kyuwon Cho ext4: validate dot entry before reading dotdot in htree readdir This commit validates the record length of the '.' entry in ext4_htree_fill_tree() against offsetof(struct dx_root, dotdot) before storing '.' or '..' into the readdir rb-tree. > diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c > index b2753daad49f4..95dd2d1a76c29 100644 > --- a/fs/ext4/namei.c > +++ b/fs/ext4/namei.c > @@ -1041,9 +1041,19 @@ int ext4_htree_fill_tree(struct file *dir_file, __= u32 start_hash, > if (IS_ERR(frame)) > return PTR_ERR(frame); > =20 > + if (start_hash < 2 || (start_hash =3D=3D 2 && start_minor_hash =3D=3D 0= )) { > + de =3D (struct ext4_dir_entry_2 *)frames[0].bh->b_data; > + if (unlikely(ext4_rec_len_from_disk(de->rec_len, > + dir->i_sb->s_blocksize) !=3D > + offsetof(struct dx_root, dotdot))) { > + EXT4_ERROR_INODE(dir, "Corrupt dir, invalid rec_len for '.'"); > + err =3D -EFSCORRUPTED; > + goto errout; > + } > + } > + > /* Add '.' and '..' from the htree header */ > if (!start_hash && !start_minor_hash) { > - de =3D (struct ext4_dir_entry_2 *) frames[0].bh->b_data; > tmp_str.name =3D de->name; > tmp_str.len =3D de->name_len; > err =3D ext4_htree_store_dirent(dir_file, 0, 0, > @@ -1053,7 +1063,6 @@ int ext4_htree_fill_tree(struct file *dir_file, __u= 32 start_hash, > count++; > } > if (start_hash < 2 || (start_hash =3D=3D2 && start_minor_hash=3D=3D0)) { > - de =3D (struct ext4_dir_entry_2 *) frames[0].bh->b_data; > de =3D ext4_next_entry(de, dir->i_sb->s_blocksize); > tmp_str.name =3D de->name; > tmp_str.len =3D de->name_len; [Severity: Low] Could both the '.' and '..' insertions be enclosed inside the new start_hash check instead of repeating the condition below? Right now, de is initialized in the first if block and used across two separate blocks below, which duplicates the hash guard and can trigger -Wmaybe-uninitialized warnings depending on the compiler. Since the check already verifies de->rec_len matches offsetof(struct dx_root, dotdot), the '..' path also does not need to re-read and decode de->rec_len via ext4_next_entry(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/179637501338.142543= 3.8835682775805888953@gmail.com?part=3D1