HomeFreeBSD

Set file mode during zfs_write

Description

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

Details

Provenance
Antonio Russo <aerusso@aerusso.net>Authored on Feb 8 2021, 5:15 PM
GitHub <noreply@github.com>Committed on Feb 8 2021, 5:15 PM
Parents
rG7c64ee9e7731: zfs-import-{cache,scan}: change condition to FileNotEmpty
Branches
Unknown
Tags
Unknown

Event Timeline

GitHub <noreply@github.com> committed rGf8ce8aed0c8d: Set file mode during zfs_write (authored by Antonio Russo <aerusso@aerusso.net>).Feb 8 2021, 5:15 PM