Commit 8519f994 authored by Kinglong Mee's avatar Kinglong Mee Committed by J. Bruce Fields

NFSD: Put file after ima_file_check fail in nfsd_open()

Signed-off-by: default avatarKinglong Mee <kinglongmee@gmail.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 66f09ca7
...@@ -649,6 +649,7 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, ...@@ -649,6 +649,7 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type,
{ {
struct path path; struct path path;
struct inode *inode; struct inode *inode;
struct file *file;
int flags = O_RDONLY|O_LARGEFILE; int flags = O_RDONLY|O_LARGEFILE;
__be32 err; __be32 err;
int host_err = 0; int host_err = 0;
...@@ -703,19 +704,25 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, ...@@ -703,19 +704,25 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type,
else else
flags = O_WRONLY|O_LARGEFILE; flags = O_WRONLY|O_LARGEFILE;
} }
*filp = dentry_open(&path, flags, current_cred());
if (IS_ERR(*filp)) { file = dentry_open(&path, flags, current_cred());
host_err = PTR_ERR(*filp); if (IS_ERR(file)) {
*filp = NULL; host_err = PTR_ERR(file);
} else { goto out_nfserr;
host_err = ima_file_check(*filp, may_flags); }
host_err = ima_file_check(file, may_flags);
if (host_err) {
nfsd_close(file);
goto out_nfserr;
}
if (may_flags & NFSD_MAY_64BIT_COOKIE) if (may_flags & NFSD_MAY_64BIT_COOKIE)
(*filp)->f_mode |= FMODE_64BITHASH; file->f_mode |= FMODE_64BITHASH;
else else
(*filp)->f_mode |= FMODE_32BITHASH; file->f_mode |= FMODE_32BITHASH;
}
*filp = file;
out_nfserr: out_nfserr:
err = nfserrno(host_err); err = nfserrno(host_err);
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment