Linux Overlay Filesystem development
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>
Cc: Shakeel Butt <shakeel.butt@linux.dev>,
	Alexander Viro	 <viro@zeniv.linux.org.uk>,
	Jens Axboe <axboe@kernel.dk>,
	 linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	 io-uring@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	 linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
	 linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	 linux-unionfs@vger.kernel.org, bpf@vger.kernel.org,
	linux-nfs@vger.kernel.org, 	stable@vger.kernel.org
Subject: Re: [PATCH v2 14/17] nfsd: take freeze protection for the truncate on open
Date: Mon, 16 Nov 2026 15:37:05 -0800	[thread overview]
Message-ID: <2cfb2d8ea3d59bfe0acead4fe5879b6f4882a920.camel@kernel.org> (raw)
In-Reply-To: <20261116-work-fs-frozen_writes-v2-14-ecc4a2aac40e@kernel.org>

On Mon, 2026-11-16 at 12:03 +0100, Christian Brauner wrote:
> An OPEN that truncates an existing file ends up in nfsd4_truncate()
> which calls nfsd_setattr() on the already verified file handle. For a
> verified file handle nfsd_setattr() leaves fh_want_write() to the
> caller but nfsd4_truncate() never takes it, and do_lookup_open() has
> dropped its own write access by then. So a freeze of the exported
> filesystem that lands in between lets the truncate modify a frozen
> filesystem.
> 
> Take write access around nfsd_setattr() like nfsd4_setattr() does.
> 
> Fixes: 9f67f189939e ("nfsd: notify_change needs elevated write count")
> Cc: stable@vger.kernel.org
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
> ---
>  fs/nfsd/nfs4state.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 1de6c6d757c3e..e561903b9180f 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -6681,11 +6681,19 @@ nfsd4_truncate(struct svc_rqst *rqstp, struct svc_fh *fh,
>  	struct nfsd_attrs attrs = {
>  		.na_iattr	= &iattr,
>  	};
> +	__be32 status;
> +	int err;
> +
>  	if (!open->op_truncate)
>  		return 0;
>  	if (!(open->op_share_access & NFS4_SHARE_ACCESS_WRITE))
>  		return nfserr_inval;
> -	return nfsd_setattr(rqstp, fh, &attrs, NULL);
> +	err = fh_want_write(fh);
> +	if (err)
> +		return nfserrno(err);
> +	status = nfsd_setattr(rqstp, fh, &attrs, NULL);
> +	fh_drop_write(fh);
> +	return status;
>  }
>  
>  static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp,


Reviewed-by: Jeff Layton <jlayton@kernel.org>

  reply	other threads:[~2026-11-16 23:37 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 11:03 [PATCH v2 00/17] fs: take freeze protection for writes to backing files Christian Brauner
2026-11-16 11:03 ` [PATCH v2 01/17] fs: add kiocb_start_write_trylock() Christian Brauner
2026-11-16 13:11   ` Jan Kara
2026-11-16 11:03 ` [PATCH v2 02/17] fs: add kiocb_write_iter() and kiocb_end_write_iter() Christian Brauner
2026-11-16 13:13   ` Jan Kara
2026-11-16 11:03 ` [PATCH v2 03/17] fs: add file_write guard Christian Brauner
2026-11-16 13:13   ` Jan Kara
2026-11-16 11:03 ` [PATCH v2 04/17] zloop: take freeze protection for writes Christian Brauner
2026-11-16 11:03 ` [PATCH v2 05/17] nvmet: take freeze protection for writes to files Christian Brauner
2026-11-16 11:03 ` [PATCH v2 06/17] target: fileio: don't free the aio command under the filesystem Christian Brauner
2026-11-16 11:03 ` [PATCH v2 07/17] target: fileio: take freeze protection for aio writes Christian Brauner
2026-11-16 11:03 ` [PATCH v2 08/17] loop: take freeze protection for discard and write zeroes Christian Brauner
2026-11-16 13:14   ` Jan Kara
2026-11-16 11:03 ` [PATCH v2 09/17] zloop: take freeze protection when recording write pointers Christian Brauner
2026-11-16 11:03 ` [PATCH v2 10/17] target: fileio: take freeze protection for unmap Christian Brauner
2026-11-16 11:03 ` [PATCH v2 11/17] coredump: take freeze protection for the truncate Christian Brauner
2026-11-16 11:03 ` [PATCH v2 12/17] ovl: take freeze protection when storing the uuid Christian Brauner
2026-11-16 11:03 ` [PATCH v2 13/17] bpf: fs/xattr: take freeze protection in the xattr kfuncs Christian Brauner
2026-11-16 20:07   ` Andrii Nakryiko
2026-11-16 11:03 ` [PATCH v2 14/17] nfsd: take freeze protection for the truncate on open Christian Brauner
2026-11-16 23:37   ` Jeff Layton [this message]
2026-11-16 11:03 ` [PATCH v2 15/17] loop: use kiocb_write_iter() Christian Brauner
2026-11-16 13:15   ` Jan Kara
2026-11-16 11:03 ` [PATCH v2 16/17] fs: use kiocb_write_iter() in vfs_iocb_iter_write() Christian Brauner
2026-11-16 13:16   ` Jan Kara
2026-11-16 11:03 ` [PATCH v2 17/17] backing-file: use kiocb_end_write_iter() Christian Brauner

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=2cfb2d8ea3d59bfe0acead4fe5879b6f4882a920.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=bpf@vger.kernel.org \
    --cc=brauner@kernel.org \
    --cc=hch@lst.de \
    --cc=io-uring@vger.kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=target-devel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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