Skip to content

Commit

Permalink
NFSv4.2 fix problems with __nfs42_ssc_open
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
olgakorn1 authored and Trond Myklebust committed Aug 20, 2022
1 parent f16857e commit fcfc8be
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fs/nfs/nfs4file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down

0 comments on commit fcfc8be

Please sign in to comment.