-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 refuses to private read/write map of immutable files on Linux #15344
ZFS refuses to private read/write map of immutable files on Linux #15344
Conversation
66fadf0
to
bacef45
Compare
@amotin this appears to be a linux specific issue, but can you double check the FreeBSD side. |
@behlendorf I am not familiar with the mmap() code, but I hope that in case of MAP_PRIVATE no write requests will ever reach ZFS to allow modification of immutable files. |
Well you're right this isn't safe. I doubled checked and sure enough the generic |
Private read/write mapping can't be used to modify the mapped files, so they will remain be immutable. Private read/write mappings are usually used to load the data segument of executable files, rejecting them will rendering immutable executable files to stop working. Signed-off-by: WHR <msl0000023508@gmail.com>
Just found #2724. |
bacef45
to
0cf4aad
Compare
Where does this get enforced if we remove this check? |
From my testings, ext4 doesn't check this on mmap(2) call at all. If a process successfully R/W **open(2)**ed a file from ext4, and the file was later made immutable, the process can still mmap(2) the file with I'm not sure whether will this get checked in ZFS too. |
Based on my reading of the code it currently won't be, so for now we have to keep this check. To do this right we'll need to register our own custom |
I think returning an On other hand this bug of rejecting |
Some more testings I have done with the fix appliedR/W and
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Low-power thanks for whipping up those test cases. I ran through it myself locally and was confirmed that in the VM_PRIVATE
case nothing written to the mapping hits disk. That addresses my concern above so this LGTM. Thanks.
Private read/write mapping can't be used to modify the mapped files, so they will remain be immutable. Private read/write mappings are usually used to load the data segment of executable files, rejecting them will rendering immutable executable files to stop working. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: WHR <msl0000023508@gmail.com> Closes openzfs#15344
Private read/write mapping can't be used to modify the mapped files, so they will remain be immutable. Private read/write mappings are usually used to load the data segment of executable files, rejecting them will rendering immutable executable files to stop working. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: WHR <msl0000023508@gmail.com> Closes openzfs#15344
Motivation and Context
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1052472
Description
Private read/write mapping can't be used to modify the underlying files, such
mapping shouldn't be rejected because the files having the immutable flag.
How Has This Been Tested?
This change has been tested with Linux 6.5 (linux-image-6.5.0-1-powerpc64 from
Debian) in a root-on-ZFS configuration. Immtuable files are still appear being
immutable.
Types of changes
Checklist:
Signed-off-by
.