]> git.baikalelectronics.ru Git - kernel.git/commitdiff
NFSv4.2 fix problems with __nfs42_ssc_open
authorOlga Kornievskaia <kolga@netapp.com>
Thu, 18 Aug 2022 19:07:05 +0000 (15:07 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Sat, 20 Aug 2022 00:31:57 +0000 (20:31 -0400)
A destination server while doing a COPY shouldn't accept using the
passed in filehandle if its not a regular filehandle.

If alloc_file_pseudo() has failed, we need to decrement a reference
on the newly created inode, otherwise it leaks.

Reported-by: Al Viro <viro@zeniv.linux.org.uk>
Fixes: 06ee3f0c4c2d5 ("NFS: inter ssc open")
Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/nfs4file.c

index e88f6b18445ece3b51ea0781861575908c393893..9eb18128787951218b3f7a898dd9747a112777de 100644 (file)
@@ -340,6 +340,11 @@ static struct file *__nfs42_ssc_open(struct vfsmount *ss_mnt,
                goto out;
        }
 
+       if (!S_ISREG(fattr->mode)) {
+               res = ERR_PTR(-EBADF);
+               goto out;
+       }
+
        res = ERR_PTR(-ENOMEM);
        len = strlen(SSC_READ_NAME_BODY) + 16;
        read_name = kzalloc(len, GFP_KERNEL);
@@ -357,6 +362,7 @@ static struct file *__nfs42_ssc_open(struct vfsmount *ss_mnt,
                                     r_ino->i_fop);
        if (IS_ERR(filep)) {
                res = ERR_CAST(filep);
+               iput(r_ino);
                goto out_free_name;
        }