lkml.org 
[lkml]   [2018]   [Jun]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 10/10] mm: Prevent munmap and remap_file_pages of shadow stack
Date
Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
---
mm/mmap.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/mm/mmap.c b/mm/mmap.c
index fc41c0543d7f..e7d1fcb7ec58 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2810,6 +2810,16 @@ EXPORT_SYMBOL(vm_munmap);

SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
{
+ struct vm_area_struct *vma;
+
+ /* Do not munmap shadow stack */
+ down_read(&current->mm->mmap_sem);
+ vma = find_vma(current->mm, addr);
+ if (vma && (vma->vm_flags & VM_SHSTK)) {
+ up_read(&current->mm->mmap_sem);
+ return -EINVAL;
+ }
+ up_read(&current->mm->mmap_sem);
profile_munmap(addr);
return vm_munmap(addr, len);
}
@@ -2851,6 +2861,9 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
if (!vma || !(vma->vm_flags & VM_SHARED))
goto out;

+ if (vma->vm_flags & VM_SHSTK)
+ goto out;
+
if (start < vma->vm_start)
goto out;

--
2.15.1
\
 
 \ /
  Last update: 2018-06-07 17:43    [W:0.277 / U:0.364 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site