Re: [PATCH v2] ntfs: validate error codes from untrusted disk data
From: Namjae Jeon
Date: Tue Jun 30 2026 - 21:59:36 EST
> diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
> index 9c1c36acfad2..e959387135b5 100644
> --- a/fs/ntfs/namei.c
> +++ b/fs/ntfs/namei.c
> @@ -233,10 +233,18 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
> d_add(dent, NULL);
> ntfs_debug("Done.");
> return NULL;
This patch seems to be written for the 7.1 kernel. Could you please
create a patch on 7.2-rc1?
> + } else {
else { } is not needed. and let's move the assignment long err =
MREF_ERR(mref); to the top of the block and reuse err instead of using
MREF_ERR(mref).
Thanks.
> + long err = MREF_ERR(mref);
> +
> + if (err < 0 && err >= -MAX_ERRNO) {
> + ntfs_error(vol->sb, "ntfs_lookup_ino_by_name() failed with error code %li.",
> + err);
> + return ERR_PTR(err);
> + }
> + ntfs_error(vol->sb, "ntfs_lookup_ino_by_name() returned invalid error code %li, treating as disk corruption.",
> + err);
> + return ERR_PTR(-EIO);
> }
> - ntfs_error(vol->sb, "ntfs_lookup_ino_by_name() failed with error code %i.",
> - -MREF_ERR(mref));
> - return ERR_PTR(MREF_ERR(mref));
> handle_name:
> {
> struct mft_record *m;
> --
> 2.25.1
>