> For ordinary files the only way the VMA_MAYWRITE_BIT flag is cleared is if
> the underlying file is itself read-only.
> 
> This means that mprotect() cannot mark a shared mapping of a read-only file
> as read/write, as doing so would violate the read only attribute, and
> permit writes.
> 
> In general, we do not want file systems to be able to do this for
> read/write files.
> 
> Doing so would violate fundamental user expectation of file attributes and
> likely break userspace.
> 
> However, drivers pose a tricky problem here - the /dev/xxx file may be
> read/write but provide access to a resource which is fundamentally
> [ ... ]
> 
> As all drivers which clear VMA_MAYWRITE_BIT establish kernel-owned
> mappings, no functional change is intended.
> 
> Signed-off-by: Lorenzo Stoakes (ARM) <[email protected]>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/20260917-b4-mmap-prepare-vma-flag-sanify-v3-0-4583d8a23...@kernel.org?part=16


Reply via email to