Skip to content

Commit fcfc8be

Browse files
olgakorn1Trond Myklebust
authored andcommitted
NFSv4.2 fix problems with __nfs42_ssc_open
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]>
1 parent f16857e commit fcfc8be

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
@@ -340,6 +340,11 @@ static struct file *__nfs42_ssc_open(struct vfsmount *ss_mnt,
340340
goto out;
341341
}
342342

343+
if (!S_ISREG(fattr->mode)) {
344+
res = ERR_PTR(-EBADF);
345+
goto out;
346+
}
347+
343348
res = ERR_PTR(-ENOMEM);
344349
len = strlen(SSC_READ_NAME_BODY) + 16;
345350
read_name = kzalloc(len, GFP_KERNEL);
@@ -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

0 commit comments

Comments
 (0)