summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlga Kornievskaia <kolga@netapp.com>2022-08-18 22:07:05 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-08-31 18:15:15 +0300
commit5e49ea099850feadcbf33c74b4f514a3e8049b91 (patch)
tree39442c6909a34a19e2158a53768082d35973593e
parent23c6f25a60435f85e1a442dd5492e96a260dd731 (diff)
downloadlinux-5e49ea099850feadcbf33c74b4f514a3e8049b91.tar.xz
NFSv4.2 fix problems with __nfs42_ssc_open
[ Upstream commit fcfc8be1e9cf2f12b50dce8b579b3ae54443a014 ] 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: ec4b092508982 ("NFS: inter ssc open") Signed-off-by: Olga Kornievskaia <kolga@netapp.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--fs/nfs/nfs4file.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
index 4928eaa0d4c0..70cd0d764c44 100644
--- a/fs/nfs/nfs4file.c
+++ b/fs/nfs/nfs4file.c
@@ -341,6 +341,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_NOFS);
@@ -359,6 +364,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;
}
filep->f_mode |= FMODE_READ;