Linux EXT4 FS development
 help / color / mirror / Atom feed
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 05/13] ext4: add dirdata format definitions and access helpers
Date: Thu, 03 Dec 2026 19:59:17 +0000	[thread overview]
Message-ID: <sashiko-outbox-248580@kernel.org> (raw)
In-Reply-To: <20261203184938.422849-6-ablagodarenko@thelustrecollective.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] ext4: ext4_dirent_get_data_len() comment omits included NUL byte
- [Low] ext4: unused ext4_dirdata_next() helper bypassed by dirdata
  parsers
--

commit 215944fd5c4851a4433f0516167e85726be4f765
Author: Artem Blagodarenko <artem.blagodarenko@gmail.com>

ext4: add dirdata format definitions and access helpers

This commit defines the on-disk flags and structures for ext4 directory
entry extension data (dirdata) and adds ext4_dirdata_next() and
ext4_dirent_get_data_len() helpers in fs/ext4/ext4.h.

> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index a7fc2c2c98e16..a75a8cedd52f6 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h

[ ... ]

> @@ -4378,6 +4427,80 @@ static inline bool ext4_dir_entry_is_tail(struct ext4_dir_entry_2 *de)
>  	       t->det_reserved_ft == EXT4_FT_DIR_CSUM;
>  }
>  
> +/*
> + * Advance to the next dirdata record header starting from @ddh.
> + *
> + * Uses READ_ONCE() on ddh_length to prevent the compiler from re-fetching this
> + * on-disk field and to guard against a concurrent write racing with any bounds
> + * check the caller performs on the returned pointer.
> + */
> +static inline struct ext4_dirent_data_header *
> +ext4_dirdata_next(struct ext4_dirent_data_header *ddh)
> +{
> +	return (struct ext4_dirent_data_header *)
> +		((char *)ddh + READ_ONCE(ddh->ddh_length));
> +}

[Severity: Low]
Is ext4_dirdata_next() needed?  Nothing in this commit or the rest of the
series calls it.

Even ext4_dirent_get_data_len() below bypasses it because callers must
read ddh->ddh_length once and validate it against zero and rec_len before
advancing, rather than re-fetching it in ext4_dirdata_next().  Consider
dropping ext4_dirdata_next() and updating the commit message.

> +
> +/*
> + * ext4_dirent_get_data_len() - Compute the total dirdata length for an entry.
> + * @de: directory entry
> + * @rec_len: the record length of the directory entry (decoded)
> + *
> + * Computes the length of optional data stored after the filename (and its
> + * implicit NUL terminator).  Each extension is indicated by a bit in the
> + * high 4 bits of de->file_type; the first byte of each extension is its
> + * length (including that length byte itself).
> + *
> + * Returns 0 for tail entries and for entries with no dirdata.
> + */

[ ... ]

> +				if (ddh_len == 0 || ddh_len > rec_len - offset)
> +					return 0;
> +				dlen += ddh_len + (dlen == 0);

[Severity: Low]
Should the comment above ext4_dirent_get_data_len() document that the
returned length includes the 1-byte NUL separator when dirdata is
present?

The comment describes only the optional data after the NUL terminator,
whereas dlen += ddh_len + (dlen == 0) adds 1 byte on the first record.
A caller that copies ext4_dirent_get_data_len() bytes starting after the
NUL byte would overread by 1 byte past rec_len.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203184938.422849-1-ablagodarenko@thelustrecollective.com?part=5

  reply	other threads:[~2026-12-03 19:59 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 [this message]
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
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-248580@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