Merge tag 'denywrite-for-5.15' of git://github.com/davidhildenbrand/linux
Pull MAP_DENYWRITE removal from David Hildenbrand:
"Remove all in-tree usage of MAP_DENYWRITE from the kernel and remove
VM_DENYWRITE.
There are some (minor) user-visible changes:
- We no longer deny write access to shared libaries loaded via legacy
uselib(); this behavior matches modern user space e.g. dlopen().
- We no longer deny write access to the elf interpreter after exec
completed, treating it just like shared libraries (which it often
is).
- We always deny write access to the file linked via /proc/pid/exe:
sys_prctl(PR_SET_MM_MAP/EXE_FILE) will fail if write access to the
file cannot be denied, and write access to the file will remain
denied until the link is effectivel gone (exec, termination,
sys_prctl(PR_SET_MM_MAP/EXE_FILE)) -- just as if exec'ing the file.
Cross-compiled for a bunch of architectures (alpha, microblaze, i386,
s390x, ...) and verified via ltp that especially the relevant tests
(i.e., creat07 and execve04) continue working as expected"
* tag 'denywrite-for-5.15' of git://github.com/davidhildenbrand/linux:
fs: update documentation of get_write_access() and friends
mm: ignore MAP_DENYWRITE in ksys_mmap_pgoff()
mm: remove VM_DENYWRITE
binfmt: remove in-tree usage of MAP_DENYWRITE
kernel/fork: always deny write access to current MM exe_file
kernel/fork: factor out replacing the current MM exe_file
binfmt: don't use MAP_DENYWRITE when loading shared libraries via uselib()
This commit is contained in:
+12
-7
@@ -3023,15 +3023,20 @@ static inline void file_end_write(struct file *file)
|
||||
}
|
||||
|
||||
/*
|
||||
* This is used for regular files where some users -- especially the
|
||||
* currently executed binary in a process, previously handled via
|
||||
* VM_DENYWRITE -- cannot handle concurrent write (and maybe mmap
|
||||
* read-write shared) accesses.
|
||||
*
|
||||
* get_write_access() gets write permission for a file.
|
||||
* put_write_access() releases this write permission.
|
||||
* This is used for regular files.
|
||||
* We cannot support write (and maybe mmap read-write shared) accesses and
|
||||
* MAP_DENYWRITE mmappings simultaneously. The i_writecount field of an inode
|
||||
* can have the following values:
|
||||
* 0: no writers, no VM_DENYWRITE mappings
|
||||
* < 0: (-i_writecount) vm_area_structs with VM_DENYWRITE set exist
|
||||
* > 0: (i_writecount) users are writing to the file.
|
||||
* deny_write_access() denies write access to a file.
|
||||
* allow_write_access() re-enables write access to a file.
|
||||
*
|
||||
* The i_writecount field of an inode can have the following values:
|
||||
* 0: no write access, no denied write access
|
||||
* < 0: (-i_writecount) users that denied write access to the file.
|
||||
* > 0: (i_writecount) users that have write access to the file.
|
||||
*
|
||||
* Normally we operate on that counter with atomic_{inc,dec} and it's safe
|
||||
* except for the cases where we don't hold i_writecount yet. Then we need to
|
||||
|
||||
Reference in New Issue
Block a user