diff options
author | Kinglong Mee <kinglongmee@gmail.com> | 2014-09-02 20:14:06 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2014-09-03 17:43:00 -0400 |
commit | 8519f994e5cf27ecdac3b0fe2a4dc7abd320643e (patch) | |
tree | fb1b745fc4d77f82be86e81aa03f2477c8b3631d /fs/nfsd | |
parent | 66f09ca717e7905e0eebe000b86e27d0274b95ac (diff) |
NFSD: Put file after ima_file_check fail in nfsd_open()
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/vfs.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index f501a9b5c9df..89d1ae3bcff7 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -649,6 +649,7 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, | |||
649 | { | 649 | { |
650 | struct path path; | 650 | struct path path; |
651 | struct inode *inode; | 651 | struct inode *inode; |
652 | struct file *file; | ||
652 | int flags = O_RDONLY|O_LARGEFILE; | 653 | int flags = O_RDONLY|O_LARGEFILE; |
653 | __be32 err; | 654 | __be32 err; |
654 | int host_err = 0; | 655 | int host_err = 0; |
@@ -703,19 +704,25 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, | |||
703 | else | 704 | else |
704 | flags = O_WRONLY|O_LARGEFILE; | 705 | flags = O_WRONLY|O_LARGEFILE; |
705 | } | 706 | } |
706 | *filp = dentry_open(&path, flags, current_cred()); | ||
707 | if (IS_ERR(*filp)) { | ||
708 | host_err = PTR_ERR(*filp); | ||
709 | *filp = NULL; | ||
710 | } else { | ||
711 | host_err = ima_file_check(*filp, may_flags); | ||
712 | 707 | ||
713 | if (may_flags & NFSD_MAY_64BIT_COOKIE) | 708 | file = dentry_open(&path, flags, current_cred()); |
714 | (*filp)->f_mode |= FMODE_64BITHASH; | 709 | if (IS_ERR(file)) { |
715 | else | 710 | host_err = PTR_ERR(file); |
716 | (*filp)->f_mode |= FMODE_32BITHASH; | 711 | goto out_nfserr; |
717 | } | 712 | } |
718 | 713 | ||
714 | host_err = ima_file_check(file, may_flags); | ||
715 | if (host_err) { | ||
716 | nfsd_close(file); | ||
717 | goto out_nfserr; | ||
718 | } | ||
719 | |||
720 | if (may_flags & NFSD_MAY_64BIT_COOKIE) | ||
721 | file->f_mode |= FMODE_64BITHASH; | ||
722 | else | ||
723 | file->f_mode |= FMODE_32BITHASH; | ||
724 | |||
725 | *filp = file; | ||
719 | out_nfserr: | 726 | out_nfserr: |
720 | err = nfserrno(host_err); | 727 | err = nfserrno(host_err); |
721 | out: | 728 | out: |