Skip to content

Commit

Permalink
nfsd: make a copy of struct iattr before calling notify_change
Browse files Browse the repository at this point in the history
[ Upstream commit d53d700 ]

notify_change can modify the iattr structure. In particular it can
end up setting ATTR_MODE when ATTR_KILL_SUID is already set, causing
a BUG() if the same iattr is passed to notify_change more than once.

Make a copy of the struct iattr before calling notify_change.

Reported-by: Zhi Li <yieli@redhat.com>
Link: https://bugzilla.redhat.com/show_bug.cgi?id=2207969
Tested-by: Zhi Li <yieli@redhat.com>
Fixes: 34b91dd ("NFSD: Make nfsd4_setattr() wait before returning NFS4ERR_DELAY")
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
jtlayton authored and gregkh committed Jun 9, 2023
1 parent dac09fe commit bd42427
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fs/nfsd/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,15 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,

inode_lock(inode);
for (retries = 1;;) {
host_err = __nfsd_setattr(dentry, iap);
struct iattr attrs;

/*
* notify_change() can alter its iattr argument, making
* @iap unsuitable for submission multiple times. Make a
* copy for every loop iteration.
*/
attrs = *iap;
host_err = __nfsd_setattr(dentry, &attrs);
if (host_err != -EAGAIN || !retries--)
break;
if (!nfsd_wait_for_delegreturn(rqstp, inode))
Expand Down

0 comments on commit bd42427

Please sign in to comment.