aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorAntonio Russo <aerusso@aerusso.net>2021-02-08 17:15:05 +0000
committerRyan Moeller <freqlabs@FreeBSD.org>2021-02-09 17:30:06 +0000
commite9d419a05357036ea2fd37218d853d2c713d55cc (patch)
tree9700bec08981b9c372877a19140b74cbdb5785a3 /sys
parent81c3f64110bb76e24d6062eafd7206c10f676d6f (diff)
downloadsrc-e9d419a05357036ea2fd37218d853d2c713d55cc.tar.gz
src-e9d419a05357036ea2fd37218d853d2c713d55cc.zip
Set file mode during zfs_write
Apply https://github.com/openzfs/zfs/pull/11576 Direct commit from upstream openzfs. Full commit message below: Set file mode during zfs_write 3d40b65 refactored zfs_vnops.c, which shared much code verbatim between Linux and BSD. After a successful write, the suid/sgid bits are reset, and the mode to be written is stored in newmode. On Linux, this was propagated to both the in-memory inode and znode, which is then updated with sa_update. 3d40b65 accidentally removed the initialization of newmode, which happened to occur on the same line as the inode update (which has been moved out of the function). The uninitialized newmode can be saved to disk, leading to a crash on stat() of that file, in addition to a merely incorrect file mode. Reviewed-by: Ryan Moeller <ryan@ixsystems.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Antonio Russo <aerusso@aerusso.net> Closes #11474 Closes #11576 Obtained from: openzfs/zfs@f8ce8aed0 MFC after: 0 days Sponsored by: iXsystems, Inc.
Diffstat (limited to 'sys')
-rw-r--r--sys/contrib/openzfs/module/zfs/zfs_vnops.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/sys/contrib/openzfs/module/zfs/zfs_vnops.c b/sys/contrib/openzfs/module/zfs/zfs_vnops.c
index 3b7c52b8dd34..2dcc231b30b6 100644
--- a/sys/contrib/openzfs/module/zfs/zfs_vnops.c
+++ b/sys/contrib/openzfs/module/zfs/zfs_vnops.c
@@ -620,6 +620,7 @@ zfs_write(znode_t *zp, uio_t *uio, int ioflag, cred_t *cr)
((zp->z_mode & S_ISUID) != 0 && uid == 0)) != 0) {
uint64_t newmode;
zp->z_mode &= ~(S_ISUID | S_ISGID);
+ newmode = zp->z_mode;
(void) sa_update(zp->z_sa_hdl, SA_ZPL_MODE(zfsvfs),
(void *)&newmode, sizeof (uint64_t), tx);
}