]> git.baikalelectronics.ru Git - kernel.git/commit
selinux: fix mprotect PROT_EXEC regression caused by mm change
authorStephen Smalley <sds@tycho.nsa.gov>
Fri, 10 Jul 2015 13:40:59 +0000 (09:40 -0400)
committerPaul Moore <pmoore@redhat.com>
Fri, 10 Jul 2015 20:45:29 +0000 (16:45 -0400)
commitd323b424d76ae5d1008c790903e499a0dc640285
treecae10710e573cd319bdfae8eab3727d91789d787
parent2a36f282257684429e80309f5fcbf7998934bdb4
selinux: fix mprotect PROT_EXEC regression caused by mm change

commit c472b8d2690464daa2c04bbbec89930aa89fa507 ("mm: shmem_zero_setup
skip security check and lockdep conflict with XFS") caused a regression
for SELinux by disabling any SELinux checking of mprotect PROT_EXEC on
shared anonymous mappings.  However, even before that regression, the
checking on such mprotect PROT_EXEC calls was inconsistent with the
checking on a mmap PROT_EXEC call for a shared anonymous mapping.  On a
mmap, the security hook is passed a NULL file and knows it is dealing
with an anonymous mapping and therefore applies an execmem check and no
file checks.  On a mprotect, the security hook is passed a vma with a
non-NULL vm_file (as this was set from the internally-created shmem
file during mmap) and therefore applies the file-based execute check
and no execmem check.  Since the aforementioned commit now marks the
shmem zero inode with the S_PRIVATE flag, the file checks are disabled
and we have no checking at all on mprotect PROT_EXEC.  Add a test to
the mprotect hook logic for such private inodes, and apply an execmem
check in that case.  This makes the mmap and mprotect checking
consistent for shared anonymous mappings, as well as for /dev/zero and
ashmem.

Cc: <stable@vger.kernel.org> # 4.1.x
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Paul Moore <pmoore@redhat.com>
security/selinux/hooks.c