mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
selinux: check MAP_SHARED_VALIDATE mappings as shared
selinux_mmap_file() only recognizes MAP_SHARED as a shared mapping,
but MAP_SHARED_VALIDATE is also a shared mapping type. The mmap flags
reach this hook before the mm code processes the mapping type.
Consequently, a writable MAP_SHARED_VALIDATE mapping was failing to
check the file write permission at mmap time, and a writable
executable file mapping was wrongly checking process execmem
permission as if it were private.
Cc: [email protected]
Link: https://github.com/SELinuxProject/selinux-kernel/issues/78
Fixes: 1c97259740 ("mm: introduce MAP_SHARED_VALIDATE, a mechanism to safely define new mmap flags")
Signed-off-by: Stephen Smalley <[email protected]>
Signed-off-by: Paul Moore <[email protected]>
This commit is contained in:
committed by
Paul Moore
parent
7475ea8b58
commit
beb0ae6bcd
@@ -4179,8 +4179,11 @@ static int selinux_mmap_file(struct file *file,
|
||||
unsigned long reqprot __always_unused,
|
||||
unsigned long prot, unsigned long flags)
|
||||
{
|
||||
const unsigned long map_type = (flags & MAP_TYPE);
|
||||
|
||||
return selinux_mmap_file_common(file, prot,
|
||||
(flags & MAP_TYPE) == MAP_SHARED,
|
||||
(map_type == MAP_SHARED ||
|
||||
map_type == MAP_SHARED_VALIDATE),
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user