]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Set file mode during zfs_write
authorAntonio Russo <aerusso@aerusso.net>
Mon, 8 Feb 2021 17:15:05 +0000 (10:15 -0700)
committerRyan Moeller <freqlabs@FreeBSD.org>
Tue, 9 Feb 2021 18:13:25 +0000 (13:13 -0500)
commit7100be11ec2e7a79b65ddb727236f23d885aa8a3
tree84c1d2a19702c4b81823e39547ee407ca9ba9acc
parentf69cd089ccf4bf6afbb61fe84e1df2af2b037ec4
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

Approved by: re (gdb)
Obtained from: openzfs/zfs@f8ce8aed0
Sponsored by: iXsystems, Inc.

(cherry picked from commit e9d419a05357036ea2fd37218d853d2c713d55cc)
(cherry picked from commit 618dee602319166c14c6e12971425d175d4630ed)
sys/contrib/openzfs/module/zfs/zfs_vnops.c