[PATCH 0/6] vfs: properly deny directory leases on filesystems with special lease handling

Jeff Layton posted 6 patches 1 month ago
fs/9p/vfs_dir.c        | 2 ++
fs/ceph/dir.c          | 2 ++
fs/gfs2/file.c         | 1 +
fs/nfs/dir.c           | 1 +
fs/nfs/nfs4file.c      | 2 --
fs/smb/client/cifsfs.c | 4 +---
fs/vboxsf/dir.c        | 1 +
7 files changed, 8 insertions(+), 5 deletions(-)
[PATCH 0/6] vfs: properly deny directory leases on filesystems with special lease handling
Posted by Jeff Layton 1 month ago
Filesystems currently have to set the ->setlease() method explicitly in
order to deny attempts to set a lease or delegation. With the advent of
directory delegations, we now need to set ->setlease on the directory
file_operations for several filesystems to simple_nosetlease() to ensure
this.

This patchset does that. There should be no noticeable change in
behavior, other than fixing the support detection in xfstests, allowing
lease/delegation tests to be properly skipped on these filesystems.

It's probably simplest to merge these all at once via Christian's tree
if he's amenable, but Acks would be welcome. Ideally these would go in
for v6.19.

Long term, I think it would be best to change leases/delegations to be
an opt-in thing, such that leases are always denied by default if the
method isn't set. That's a larger patchset though as we'd need to audit
all of the file_operations that currently have ->setlease() as NULL.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
Jeff Layton (6):
      nfs: properly disallow delegation requests on directories
      smb/client: properly disallow delegations on directories
      9p: don't allow delegations to be set on directories
      gfs2: don't allow delegations to be set on directories
      ceph: don't allow delegations to be set on directories
      vboxsf: don't allow delegations to be set on directories

 fs/9p/vfs_dir.c        | 2 ++
 fs/ceph/dir.c          | 2 ++
 fs/gfs2/file.c         | 1 +
 fs/nfs/dir.c           | 1 +
 fs/nfs/nfs4file.c      | 2 --
 fs/smb/client/cifsfs.c | 4 +---
 fs/vboxsf/dir.c        | 1 +
 7 files changed, 8 insertions(+), 5 deletions(-)
---
base-commit: 7f98ab9da046865d57c102fd3ca9669a29845f67
change-id: 20260107-setlease-6-19-3ab7a5d30c51

Best regards,
-- 
Jeff Layton <jlayton@kernel.org>
Re: [PATCH 0/6] vfs: properly deny directory leases on filesystems with special lease handling
Posted by Christian Brauner 3 weeks, 5 days ago
On Wed, 07 Jan 2026 09:20:08 -0500, Jeff Layton wrote:
> Filesystems currently have to set the ->setlease() method explicitly in
> order to deny attempts to set a lease or delegation. With the advent of
> directory delegations, we now need to set ->setlease on the directory
> file_operations for several filesystems to simple_nosetlease() to ensure
> this.
> 
> This patchset does that. There should be no noticeable change in
> behavior, other than fixing the support detection in xfstests, allowing
> lease/delegation tests to be properly skipped on these filesystems.
> 
> [...]

Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes

[1/6] nfs: properly disallow delegation requests on directories
      https://git.kernel.org/vfs/vfs/c/10dcd5110678
[2/6] smb/client: properly disallow delegations on directories
      https://git.kernel.org/vfs/vfs/c/b9a9be4d3557
[3/6] 9p: don't allow delegations to be set on directories
      https://git.kernel.org/vfs/vfs/c/5d65a70bd043
[4/6] gfs2: don't allow delegations to be set on directories
      https://git.kernel.org/vfs/vfs/c/ce946c4fb98c
[5/6] ceph: don't allow delegations to be set on directories
      https://git.kernel.org/vfs/vfs/c/ffb321045b0f
[6/6] vboxsf: don't allow delegations to be set on directories
      https://git.kernel.org/vfs/vfs/c/8a5511eeaa5c
Re: [PATCH 0/6] vfs: properly deny directory leases on filesystems with special lease handling
Posted by Christoph Hellwig 1 month ago
On Wed, Jan 07, 2026 at 09:20:08AM -0500, Jeff Layton wrote:
> Long term, I think it would be best to change leases/delegations to be
> an opt-in thing, such that leases are always denied by default if the
> method isn't set.

Agreed.

> That's a larger patchset though as we'd need to audit
> all of the file_operations that currently have ->setlease() as NULL.

Initially you can just wire them up everywhere.  But I guess that would
be overkill.
Re: [PATCH 0/6] vfs: properly deny directory leases on filesystems with special lease handling
Posted by Jeff Layton 1 month ago
On Wed, 2026-01-07 at 07:32 -0800, Christoph Hellwig wrote:
> On Wed, Jan 07, 2026 at 09:20:08AM -0500, Jeff Layton wrote:
> > Long term, I think it would be best to change leases/delegations to be
> > an opt-in thing, such that leases are always denied by default if the
> > method isn't set.
> 
> Agreed.
> 
> > That's a larger patchset though as we'd need to audit
> > all of the file_operations that currently have ->setlease() as NULL.
> 
> Initially you can just wire them up everywhere.  But I guess that would
> be overkill. 

That is probably the simplest approach, but there are literally
thousands of file_operations structures. Most are in driver code and
have no business dealing with leases. Technically, I guess you can set
a lease on those fd's today, but likely no one ever does it. We
probably also don't really need lease support in (e.g.) sysfs, debugfs,
etc. I'm not sure if there is anything that prevents them there.

I think what we probably want to do is wire them up in most filesystems
under fs/. Basically, in anything that might reasonably be exportable
via NFS or SMB, and have the rest deny them.

We might get a few regressions with that approach but if so we would
have an opportunity to dig into why people are setting leases on these
more "exotic" filesystems too.

-- 
Jeff Layton <jlayton@kernel.org>