Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZFS_READONLY flag is not enforced on write #16508

Open
tuxoko opened this issue Sep 4, 2024 · 0 comments
Open

ZFS_READONLY flag is not enforced on write #16508

tuxoko opened this issue Sep 4, 2024 · 0 comments
Labels
Type: Defect Incorrect behavior (e.g. crash, hang)

Comments

@tuxoko
Copy link
Contributor

tuxoko commented Sep 4, 2024

System information

Type Version/Name
Distribution Name ubuntu
Distribution Version
Kernel Version
Architecture
OpenZFS Version master

Describe the problem you're observing

The dos attribute ZFS_READONLY is enforced on truncate but not on write.

There was a change that moved the ZFS_READONLY check from zfs_write() to zfs_zaccess_common().
https://github.com/openzfs/zfs/pull/11693/files
From the commit message, the intention seems to be allowing write if open is before readonly flag is set.
However, currently write will succeed no matter open is before or after.
Note, there's an issue in the change where it checks S_ISDIR(ZTOI(zp)->i_mode) instead of !S_ISDIR(ZTOI(zp)->i_mode).
However, even if this check is fixed, it makes no difference.
It doesn't seem like zfs_zaccess_common is ever called during open(2) or write(2) at all, I added a kprobe on it but nothing showed up.

Describe how to reproduce the problem

$ rm -f /pp/asdf
$ touch /pp/asdf
$ /usr/local/share/zfs/zfs-tests/bin/write_dos_attributes readonly /pp/asdf
0x900000000
$ truncate -s 0 /pp/asdf
truncate: failed to truncate '/pp/asdf' at 0 bytes: Operation not permitted
$ ~/test_write /pp/asdf
$ cat /pp/asdf
test
append

Include any warning/errors/backtraces from the system logs

@tuxoko tuxoko added the Type: Defect Incorrect behavior (e.g. crash, hang) label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Defect Incorrect behavior (e.g. crash, hang)
Projects
None yet
Development

No branches or pull requests

1 participant