Skip to content

Commit d53d700

Browse files
jtlaytonchucklever
authored andcommitted
nfsd: make a copy of struct iattr before calling notify_change
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 <[email protected]> Link: https://bugzilla.redhat.com/show_bug.cgi?id=2207969 Tested-by: Zhi Li <[email protected]> Fixes: 34b91dd ("NFSD: Make nfsd4_setattr() wait before returning NFS4ERR_DELAY") Signed-off-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 21a3f33 commit d53d700

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

fs/nfsd/vfs.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,15 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
536536

537537
inode_lock(inode);
538538
for (retries = 1;;) {
539-
host_err = __nfsd_setattr(dentry, iap);
539+
struct iattr attrs;
540+
541+
/*
542+
* notify_change() can alter its iattr argument, making
543+
* @iap unsuitable for submission multiple times. Make a
544+
* copy for every loop iteration.
545+
*/
546+
attrs = *iap;
547+
host_err = __nfsd_setattr(dentry, &attrs);
540548
if (host_err != -EAGAIN || !retries--)
541549
break;
542550
if (!nfsd_wait_for_delegreturn(rqstp, inode))

0 commit comments

Comments
 (0)