Skip to content

Commit b9a9be4

Browse files
jtlaytonbrauner
authored andcommitted
smb/client: properly disallow delegations on directories
The check for S_ISREG() in cifs_setlease() is incorrect since that operation doesn't get called for directories. The correct way to prevent delegations on directories is to set the ->setlease() method in directory file_operations to simple_nosetlease(). Fixes: e6d28eb ("filelock: push the S_ISREG check down to ->setlease handlers") Signed-off-by: Jeff Layton <jlayton@kernel.org> Link: https://patch.msgid.link/20260107-setlease-6-19-v1-2-85f034abcc57@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 10dcd51 commit b9a9be4

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

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

0 commit comments

Comments
 (0)