diff options
author | Antonio Russo <[email protected]> | 2021-02-08 10:15:05 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2021-02-08 09:15:05 -0800 |
commit | f8ce8aed0c8d1bf0b18f461863e68eae74a83585 (patch) | |
tree | 1af94ac369fe4a418e25a75f433b908740467aa6 /module | |
parent | 7c64ee9e7731b7ad39e300b4a422892dbe8d4b23 (diff) |
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 <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Antonio Russo <[email protected]>
Closes #11474
Closes #11576
Diffstat (limited to 'module')
-rw-r--r-- | module/zfs/zfs_vnops.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index 1501b01e2..8c4c19d96 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -621,6 +621,7 @@ zfs_write(znode_t *zp, zfs_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); } |