Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: e6d28ebc17eb ("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>

authored by

Jeff Layton and committed by
Christian Brauner
b9a9be4d 10dcd511

+1 -3
+1 -3
fs/smb/client/cifsfs.c
··· 1149 1149 struct inode *inode = file_inode(file); 1150 1150 struct cifsFileInfo *cfile = file->private_data; 1151 1151 1152 - if (!S_ISREG(inode->i_mode)) 1153 - return -EINVAL; 1154 - 1155 1152 /* Check if file is oplocked if this is request for new lease */ 1156 1153 if (arg == F_UNLCK || 1157 1154 ((arg == F_RDLCK) && CIFS_CACHE_READ(CIFS_I(inode))) || ··· 1709 1712 .remap_file_range = cifs_remap_file_range, 1710 1713 .llseek = generic_file_llseek, 1711 1714 .fsync = cifs_dir_fsync, 1715 + .setlease = simple_nosetlease, 1712 1716 }; 1713 1717 1714 1718 static void