Linux fsverity development list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Eric Biggers" <ebiggers@kernel.org>
Cc: fsverity@lists.linux.dev, dsterba@suse.cz
Subject: Re: [PATCH 6.6 1/2] fs,fsverity: reject size changes on fsverity files in setattr_prepare
Date: Tue, 06 Oct 2026 21:47:00 +0000	[thread overview]
Message-ID: <sashiko-outbox-162468@kernel.org> (raw)
In-Reply-To: <20261006213815.47194-2-ebiggers@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] fs: setattr_prepare bypasses fsverity immutability if CONFIG_FS_VERITY=n
--

commit 124beac2c5f385e936a45c9aaf9bc8b5a46a9785
Author: Christoph Hellwig <hch@lst.de>

fs,fsverity: reject size changes on fsverity files in setattr_prepare
    
Add the check to reject truncates of fsverity files directly to
setattr_prepare instead of requiring the file system to handle it.
Besides removing boilerplate code, this also fixes the complete lack of
such check in btrfs.

Link: https://lore.kernel.org/r/20260128152630.627409-2-hch@lst.de

> diff --git a/fs/attr.c b/fs/attr.c
> index a8ae5f6d9b167..c2302fc4b3330 100644
> --- a/fs/attr.c
> +++ b/fs/attr.c
> @@ -173,7 +173,17 @@ int setattr_prepare(struct mnt_idmap *idmap, struct dentry *dentry,
>  	 * ATTR_FORCE.
>  	 */
>  	if (ia_valid & ATTR_SIZE) {
> -		int error = inode_newsize_ok(inode, attr->ia_size);
> +		int error;
> +
> +		/*
> +		 * Verity files are immutable, so deny truncates.  This isn't
> +		 * covered by the open-time check because sys_truncate() takes a
> +		 * path, not an open file.
> +		 */
> +		if (IS_ENABLED(CONFIG_FS_VERITY) && IS_VERITY(inode))
> +			return -EPERM;

[Severity: High]
Is it possible that this IS_ENABLED() guard bypasses the immutability check
when verity is disabled in the kernel?

Ext4 and F2FS previously relied on fsverity_prepare_setattr() which correctly
returned -EOPNOTSUPP on non-verity kernels. By replacing those checks with
this code, if the kernel is compiled without CONFIG_FS_VERITY, this check
evaluates to false and the truncation is allowed to proceed.

Can an unprivileged user with write permissions to a verity file use
sys_truncate() to destroy its contents and cryptographically sealed metadata
on a kernel compiled without CONFIG_FS_VERITY support?

While I noticed this issue is addressed later in the series by commit
0129f7fd3696d1d9b07abe1ecccfcb575dde56d8 ("fs,fsverity: remove check for
fsverity being enabled in setattr_prepare()"), shouldn't this patch be
self-contained and not introduce new regressions?

> +
> +		error = inode_newsize_ok(inode, attr->ia_size);
>  		if (error)
>  			return error;
>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261006213815.47194-1-ebiggers@kernel.org?part=1

  reply	other threads:[~2026-10-06 21:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06 21:38 [PATCH 6.6 0/2] Forbid truncate of fsverity files on btrfs Eric Biggers
2026-10-06 21:38 ` [PATCH 6.6 1/2] fs,fsverity: reject size changes on fsverity files in setattr_prepare Eric Biggers
2026-10-06 21:47   ` sashiko-bot [this message]
2026-10-06 21:38 ` [PATCH 6.6 2/2] fs,fsverity: remove check for fsverity being enabled in setattr_prepare() Eric Biggers
2026-10-07 21:03 ` [PATCH 6.6 0/2] Forbid truncate of fsverity files on btrfs Sasha Levin

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-162468@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dsterba@suse.cz \
    --cc=ebiggers@kernel.org \
    --cc=fsverity@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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