Skip to content

Commit 7d42f2b

Browse files
committed
Merge patch series "vfs: properly deny directory leases on filesystems with special lease handling"
Jeff Layton <jlayton@kernel.org> says: 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. * patches from https://patch.msgid.link/20260107-setlease-6-19-v1-0-85f034abcc57@kernel.org: vboxsf: don't allow delegations to be set on directories ceph: don't allow delegations to be set on directories gfs2: don't allow delegations to be set on directories 9p: don't allow delegations to be set on directories smb/client: properly disallow delegations on directories nfs: properly disallow delegation requests on directories Link: https://patch.msgid.link/20260107-setlease-6-19-v1-0-85f034abcc57@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
2 parents cab0123 + 8a5511e commit 7d42f2b

File tree

7 files changed

+8
-5
lines changed

7 files changed

+8
-5
lines changed

fs/9p/vfs_dir.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ const struct file_operations v9fs_dir_operations = {
242242
.iterate_shared = v9fs_dir_readdir,
243243
.open = v9fs_file_open,
244244
.release = v9fs_dir_release,
245+
.setlease = simple_nosetlease,
245246
};
246247

247248
const struct file_operations v9fs_dir_operations_dotl = {
@@ -251,4 +252,5 @@ const struct file_operations v9fs_dir_operations_dotl = {
251252
.open = v9fs_file_open,
252253
.release = v9fs_dir_release,
253254
.fsync = v9fs_file_fsync_dotl,
255+
.setlease = simple_nosetlease,
254256
};

fs/ceph/dir.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,13 +2214,15 @@ const struct file_operations ceph_dir_fops = {
22142214
.fsync = ceph_fsync,
22152215
.lock = ceph_lock,
22162216
.flock = ceph_flock,
2217+
.setlease = simple_nosetlease,
22172218
};
22182219

22192220
const struct file_operations ceph_snapdir_fops = {
22202221
.iterate_shared = shared_ceph_readdir,
22212222
.llseek = ceph_dir_llseek,
22222223
.open = ceph_open,
22232224
.release = ceph_release,
2225+
.setlease = simple_nosetlease,
22242226
};
22252227

22262228
const struct inode_operations ceph_dir_iops = {

fs/gfs2/file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,7 @@ const struct file_operations gfs2_dir_fops = {
16081608
.lock = gfs2_lock,
16091609
.flock = gfs2_flock,
16101610
.llseek = default_llseek,
1611+
.setlease = simple_nosetlease,
16111612
.fop_flags = FOP_ASYNC_LOCK,
16121613
};
16131614

fs/nfs/dir.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ const struct file_operations nfs_dir_operations = {
6666
.open = nfs_opendir,
6767
.release = nfs_closedir,
6868
.fsync = nfs_fsync_dir,
69+
.setlease = simple_nosetlease,
6970
};
7071

7172
const struct address_space_operations nfs_dir_aops = {

fs/nfs/nfs4file.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,6 @@ void nfs42_ssc_unregister_ops(void)
431431
static int nfs4_setlease(struct file *file, int arg, struct file_lease **lease,
432432
void **priv)
433433
{
434-
if (!S_ISREG(file_inode(file)->i_mode))
435-
return -EINVAL;
436434
return nfs4_proc_setlease(file, arg, lease, priv);
437435
}
438436

fs/smb/client/cifsfs.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,9 +1149,6 @@ cifs_setlease(struct file *file, int arg, struct file_lease **lease, void **priv
11491149
struct inode *inode = file_inode(file);
11501150
struct cifsFileInfo *cfile = file->private_data;
11511151

1152-
if (!S_ISREG(inode->i_mode))
1153-
return -EINVAL;
1154-
11551152
/* Check if file is oplocked if this is request for new lease */
11561153
if (arg == F_UNLCK ||
11571154
((arg == F_RDLCK) && CIFS_CACHE_READ(CIFS_I(inode))) ||
@@ -1712,6 +1709,7 @@ const struct file_operations cifs_dir_ops = {
17121709
.remap_file_range = cifs_remap_file_range,
17131710
.llseek = generic_file_llseek,
17141711
.fsync = cifs_dir_fsync,
1712+
.setlease = simple_nosetlease,
17151713
};
17161714

17171715
static void

fs/vboxsf/dir.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ const struct file_operations vboxsf_dir_fops = {
186186
.release = vboxsf_dir_release,
187187
.read = generic_read_dir,
188188
.llseek = generic_file_llseek,
189+
.setlease = simple_nosetlease,
189190
};
190191

191192
/*

0 commit comments

Comments
 (0)