zfs/tests/runfiles
Pawel Jakub Dawidek 3d244b4881
Fix clearing set-uid and set-gid bits on a file when replying a write
POSIX requires that set-uid and set-gid bits to be removed when an
unprivileged user writes to a file and ZFS does that during normal
operation.

The problem arrises when the write is stored in the ZIL and replayed.
During replay we have no access to original credentials of the process
doing the write, so zfs_write() will be performed with the root
credentials. When root is doing the write set-uid and set-gid bits
are not removed from the file.

To correct that, log a separate TX_SETATTR entry that removed those bits
on first write to such file.

Idea from:	Christian Schwarz

Add test for ZIL replay of setuid/setgid clearing.

Improve various edge cases when clearing setid bits:
- The setid bits can be readded during a single write, so make sure to check
  for them on every chunk write.
- Log TX_SETATTR record at most once per transaction group (if the setid bits
  are keep coming back).
- Move zfs_log_setattr() outside of zp->z_acl_lock.

Reviewed-by: Dan McDonald <danmcd@joyent.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Co-authored-by: Christian Schwarz <me@cschwarz.com>
Signed-off-by: Pawel Jakub Dawidek <pawel@dawidek.net>
Closes #13027
2022-02-03 14:37:57 -08:00
..
Makefile.am Add sanity.run file 2020-12-03 10:49:39 -08:00
common.run Fix clearing set-uid and set-gid bits on a file when replying a write 2022-02-03 14:37:57 -08:00
freebsd.run ZTS: Add tests for DOS mode attributes 2021-03-16 15:00:14 -07:00
linux.run pam_zfs_key: tests: check if zfs load-key works on short passphrases 2021-11-30 11:52:21 -08:00
longevity.run OpenZFS 9166 - zfs storage pool checkpoint 2018-06-26 10:07:42 -07:00
perf-regression.run OpenZFS 9184 - Add ZFS performance test for fixed blocksize random read/write IO 2018-07-02 13:46:06 -07:00
sanity.run Temporarily remove tests from sanity runfile 2021-12-01 13:22:52 -08:00
sunos.run ZTS: Add a failsafe callback to run after each test 2020-03-10 11:00:56 -07:00