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=1796330276; b=uOA4eWJosvYI8ORXv7oaHVcXwTOAlYbvUEkK7Yqdw4mWdUX64qYEsIve3iZxVj4Rngo1 9X1KCln1tz7FfpqbmzU8sfX4zcX5AB01DQtyjnodwjRaTjMzbY92cN9LnhjQGwvmaxo8v 8C/ADYsoaxEj3Vwajnfxd3sWklSLe6Wbv/qMz2a6HoS0BJN2kTwo8XduOt5KIGuREKvVr WfDbo+4kBwyOI7azP8XIbw1z+DyFfE5+Ewwsw1uWC3GyN7k9Y0xpYbjRiCmJes97vSZ6T U1+P4rM6+er5/Bp0CjLDP5YCBN8bf6fQXd69+gL3AoAkuVVx3Pelm26SA9RDFESu/bA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796330276; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=+WIkJ9Z233185RUNPLAdy+pGi7Emj9nr6BRLLxsODL8=; b=t+nGuci/RZFnBzXhSikS8RESPeixlvQH6CT/4AZZRxYxNhBNOVLI7a0CsNmP1qiKyqQI 6t2oJpVBeB6DjxQz21C1+/bOxfsEcSn3ef9h4ct6AH2FMCgn9BTlblEN++CMc2CklA+DU QsYQah8vgkzlkmcjGnqPRvsFeadteuTert0d5gPgHOGIZ++qVNKwaz+gHYCEz2nzEINjK Z7VWYPFjZpu7vnMDWLDbce2sHdpkmk9egTeo3JaZ4wXORWvJ84sZp0Vdo2bt6wTa7AQh4 GYJrMbp0PPkewEnA3Rk6l0FK0mTP+nD1rjzB3ABGCC771td0tOtgQ84K8Rv53RYgZ4w== 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=SsiBuwVG; 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 BB647606A322 for ; Thu, 3 Dec 2026 20:37:56 +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=SsiBuwVG Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33BD91F000CE; Thu, 3 Dec 2026 20:37:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796330276; bh=+WIkJ9Z233185RUNPLAdy+pGi7Emj9nr6BRLLxsODL8=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=SsiBuwVGP8a4/pCNa7co6jImLbWzF530iTxbsxUWz1dcNKrQBjWO+ewVw2QiRFlHf K1CrvGcNZ7ZU22xa52uAw5lZqgZO3c2KEKSoE+aCNGt1prcrD7Ed/tF+HiAl+Xk5Zy kq8HN8clJ+11c8Ad7QE7Am3y5XqDHVwEOx/GRtaY4kVvDkXdaFusuwWZn3WOYKe/2r mO6cvj8+/OfbiPmQkua0ONq6RVGc1I7YWo73z8b3FhbB61MEnHew6pNMvj/v7UaFw0 Ak7zqyNV+AEnnuPdD9d8WEvG5/Ki0fuRiXsZTeFA1giYny9ZqLKbhZL/ZgkEr9D+32 kiByeIdX7GLfw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v15 07/13] ext4: size the htree root from where its dx_entry array starts Reply-To: sashiko-reviews@lists.linux.dev To: "Artem Blagodarenko" , linux-ext4@vger.kernel.org Cc: tytso@mit.edu In-Reply-To: <20261203184938.422849-8-ablagodarenko@thelustrecollective.com> References: <20261203184938.422849-1-ablagodarenko@thelustrecollective.com> <20261203184938.422849-8-ablagodarenko@thelustrecollective.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 20:37:55 +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: dx_get_dx_info() omits 4-byte alignment check on dot rec_len - [Low] ext4: get_dtype() masks upper file_type bits without checking dirdata feature -- commit 59d75705ec9b16d55848b1ae1482b360635d7868 Author: Artem Blagodarenko ext4: size the htree root from where its dx_entry array starts This commit changes dx_root_limit() to take the byte offset of the dx_entry array instead of the dx_root_info size, updates its callers and KUnit tests accordingly, and masks dirdata flags out of file_type in get_dtype(). > diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h > index aa45735a9bb79..32401150503eb 100644 > --- a/fs/ext4/ext4.h > +++ b/fs/ext4/ext4.h > @@ -3108,12 +3108,14 @@ static const unsigned char ext4_filetype_table[] = =3D { > DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK > }; > =20 > -static inline unsigned char get_dtype(struct super_block *sb, int filet= ype) > +static inline unsigned char get_dtype(struct super_block *sb, int filety= pe) > { > - if (!ext4_has_feature_filetype(sb) || filetype >=3D EXT4_FT_MAX) > + unsigned char fl_index =3D filetype & EXT4_FT_MASK; > + > + if (!ext4_has_feature_filetype(sb) || fl_index >=3D EXT4_FT_MAX) > return DT_UNKNOWN; > =20 > - return ext4_filetype_table[filetype]; > + return ext4_filetype_table[fl_index]; > } [Severity: Low] Should this mask filetype with EXT4_FT_MASK only when ext4_has_feature_dirdata(sb) is set? On non-dirdata filesystems, a corrupted entry with upper file_type bits set (such as 0x11) previously returned DT_UNKNOWN to readdir, and now reports a concrete DT_* type like DT_REG. Also, this readdir file-type change is unrelated to sizing the htree root and would be cleaner in a separate patch. [ ... ] > diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c > index edbe033b623e6..78ee4936e6cc4 100644 > --- a/fs/ext4/namei.c > +++ b/fs/ext4/namei.c [ ... ] > @@ -749,10 +749,10 @@ dx_probe(struct ext4_filename *fname, struct inode = *dir, > =20 > entries =3D (struct dx_entry *)(((char *)info) + info->info_length); > =20 > - if (dx_get_limit(entries) !=3D dx_root_limit(dir, info->info_length)) { > + limit =3D dx_root_limit(dir, (char *)entries - frame->bh->b_data); > + if (dx_get_limit(entries) !=3D limit) { > ext4_warning_inode(dir, "dx entry: limit %u !=3D root limit %u", > - dx_get_limit(entries), > - dx_root_limit(dir, info->info_length)); > + dx_get_limit(entries), limit); > goto fail; > } [Severity: Medium] Can entries land on an unaligned offset here if dot's rec_len is not 4-byte aligned? dx_probe() reads block 0 via ext4_read_dirblock(), which does not run __ext4_check_dir_entry(), and dx_get_dx_info() does not check alignment on dot's rec_len: fs/ext4/namei.c:dx_get_dx_info() { ... rlen =3D ext4_rec_len_from_disk(de->rec_len, blocksize); if (rlen < EXT4_BASE_DIR_LEN || rlen + EXT4_BASE_DIR_LEN > blocksize || ext4_dir_entry_len(de, blocksize, NULL) > rlen) return ERR_PTR(-EFSCORRUPTED); off =3D rlen; ... } On a corrupted htree root block with an odd dot rec_len (such as 13), dotdot, info, and entries all land at odd offsets. Dereferencing the non-packed dx_root_info, dx_countlimit, and dx_entry fields then causes alignment traps on strict-alignment architectures and CONFIG_UBSAN_ALIGNMENT warnings. Checking rlen & EXT4_DIR_ROUND in dx_get_dx_info() (and ext4_check_dx_root()) would reject unaligned offsets. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203184938.4228= 49-1-ablagodarenko@thelustrecollective.com?part=3D7