From: sashiko-bot@kernel.org
To: "Artem Blagodarenko" <artem.blagodarenko@gmail.com>,
linux-ext4@vger.kernel.org
Cc: tytso@mit.edu
Subject: Re: [PATCH v15 07/13] ext4: size the htree root from where its dx_entry array starts
Date: Thu, 03 Dec 2026 20:37:55 +0000 [thread overview]
Message-ID: <sashiko-outbox-248641@kernel.org> (raw)
In-Reply-To: <20261203184938.422849-8-ablagodarenko@thelustrecollective.com>
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 <artem.blagodarenko@gmail.com>
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[] = {
> DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK
> };
>
> -static inline unsigned char get_dtype(struct super_block *sb, int filetype)
> +static inline unsigned char get_dtype(struct super_block *sb, int filetype)
> {
> - if (!ext4_has_feature_filetype(sb) || filetype >= EXT4_FT_MAX)
> + unsigned char fl_index = filetype & EXT4_FT_MASK;
> +
> + if (!ext4_has_feature_filetype(sb) || fl_index >= EXT4_FT_MAX)
> return DT_UNKNOWN;
>
> - 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,
>
> entries = (struct dx_entry *)(((char *)info) + info->info_length);
>
> - if (dx_get_limit(entries) != dx_root_limit(dir, info->info_length)) {
> + limit = dx_root_limit(dir, (char *)entries - frame->bh->b_data);
> + if (dx_get_limit(entries) != limit) {
> ext4_warning_inode(dir, "dx entry: limit %u != 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 = 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 = 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.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203184938.422849-1-ablagodarenko@thelustrecollective.com?part=7
next prev parent reply other threads:[~2026-12-03 20:37 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 18:49 [PATCH v15 00/13] Data in direntry (dirdata) feature, with KUnit tests Artem Blagodarenko
2026-12-03 18:49 ` [PATCH v15 01/13] ext4: validate count against limit in ext4_dx_csum_verify/_set Artem Blagodarenko
2026-12-03 19:03 ` sashiko-bot
2026-12-03 18:49 ` [PATCH v15 02/13] ext4: use the e2fsck limit for htree index nodes Artem Blagodarenko
2026-12-03 18:49 ` [PATCH v15 03/13] ext4: replace ext4_dir_entry with ext4_dir_entry_2 Artem Blagodarenko
2026-12-03 19:33 ` sashiko-bot
2026-12-03 18:49 ` [PATCH v15 04/13] ext4: add ext4_dir_entry_is_tail() Artem Blagodarenko
2026-12-03 18:49 ` [PATCH v15 05/13] ext4: add dirdata format definitions and access helpers Artem Blagodarenko
2026-12-03 19:59 ` sashiko-bot
2026-12-03 18:49 ` [PATCH v15 06/13] ext4: refactor dx_root to support variable dirent sizes Artem Blagodarenko
2026-12-03 20:21 ` sashiko-bot
2026-12-03 18:49 ` [PATCH v15 07/13] ext4: size the htree root from where its dx_entry array starts Artem Blagodarenko
2026-12-03 20:37 ` sashiko-bot [this message]
2026-12-03 18:49 ` [PATCH v15 08/13] ext4: rename ext4_dir_rec_len() and clarify dirdata usage Artem Blagodarenko
2026-12-03 21:05 ` sashiko-bot
2026-12-03 18:49 ` [PATCH v15 09/13] ext4: dirdata feature Artem Blagodarenko
2026-12-03 21:37 ` sashiko-bot
2026-12-03 18:49 ` [PATCH v15 10/13] ext4: add dirdata LUFID support for directory entry rename Artem Blagodarenko
2026-12-03 22:02 ` sashiko-bot
2026-12-03 18:49 ` [PATCH v15 11/13] ext4: add dirdata set/get helpers Artem Blagodarenko
2026-12-03 22:30 ` sashiko-bot
2026-12-03 18:49 ` [PATCH v15 12/13] ext4: Add EXT4_IOC_SET_LUFID ioctl for setting LUFID on directory entries Artem Blagodarenko
2026-12-03 23:01 ` sashiko-bot
2026-12-03 18:49 ` [PATCH v15 13/13] ext4: add KUnit tests for dirdata Artem Blagodarenko
2026-12-03 23:15 ` sashiko-bot
2026-12-03 23:15 ` [PATCH v15 00/13] Data in direntry (dirdata) feature, with KUnit tests sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-248641@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=artem.blagodarenko@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox