Skip to content

Commit

Permalink
nfsd: notify_change needs elevated write count
Browse files Browse the repository at this point in the history
Looks like this bug has been here since these write counts were
introduced, not sure why it was just noticed now.

Thanks also to Jan Kara for pointing out the problem.

Cc: stable@vger.kernel.org
Reported-by: Matthew Rahtz <mrahtz@rapitasystems.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
  • Loading branch information
J. Bruce Fields committed Mar 27, 2014
1 parent a11fcce commit 9f67f18
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions fs/nfsd/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,17 +404,26 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
umode_t ftype = 0;
__be32 err;
int host_err;
bool get_write_count;
int size_change = 0;

if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE))
accmode |= NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE;
if (iap->ia_valid & ATTR_SIZE)
ftype = S_IFREG;

/* Callers that do fh_verify should do the fh_want_write: */
get_write_count = !fhp->fh_dentry;

/* Get inode */
err = fh_verify(rqstp, fhp, ftype, accmode);
if (err)
goto out;
if (get_write_count) {
host_err = fh_want_write(fhp);
if (host_err)
return nfserrno(host_err);
}

dentry = fhp->fh_dentry;
inode = dentry->d_inode;
Expand Down

0 comments on commit 9f67f18

Please sign in to comment.