Skip to content

Commit 10dcd51

Browse files
jtlaytonbrauner
authored andcommitted
nfs: properly disallow delegation requests on directories
Checking for S_ISREG() in nfs4_setlease() is incorrect, since that op is never called for directories. The right way to deny lease requests on directories is to set the ->setlease() operation to simple_nosetlease() in the directory file_operations. Fixes: e6d28eb ("filelock: push the S_ISREG check down to ->setlease handlers") Reported-by: Christoph Hellwig <hch@infradead.org> Closes: https://lore.kernel.org/linux-fsdevel/aV316LhsVSl0n9-E@infradead.org/ Signed-off-by: Jeff Layton <jlayton@kernel.org> Link: https://patch.msgid.link/20260107-setlease-6-19-v1-1-85f034abcc57@kernel.org Tested-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent cab0123 commit 10dcd51

2 files changed

Lines changed: 1 addition & 2 deletions

File tree

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

0 commit comments

Comments
 (0)