Skip to content

Commit 5626f95

Browse files
olgakorn1gregkh
authored andcommitted
NFSv4.2 fix problems with __nfs42_ssc_open
[ Upstream commit fcfc8be ] 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 <[email protected]> Fixes: ec4b092 ("NFS: inter ssc open") Signed-off-by: Olga Kornievskaia <[email protected]> Signed-off-by: Trond Myklebust <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 519543a commit 5626f95

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/nfs/nfs4file.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ static struct file *__nfs42_ssc_open(struct vfsmount *ss_mnt,
339339
goto out;
340340
}
341341

342+
if (!S_ISREG(fattr->mode)) {
343+
res = ERR_PTR(-EBADF);
344+
goto out;
345+
}
346+
342347
res = ERR_PTR(-ENOMEM);
343348
len = strlen(SSC_READ_NAME_BODY) + 16;
344349
read_name = kzalloc(len, GFP_NOFS);
@@ -357,6 +362,7 @@ static struct file *__nfs42_ssc_open(struct vfsmount *ss_mnt,
357362
r_ino->i_fop);
358363
if (IS_ERR(filep)) {
359364
res = ERR_CAST(filep);
365+
iput(r_ino);
360366
goto out_free_name;
361367
}
362368
filep->f_mode |= FMODE_READ;

0 commit comments

Comments
 (0)