Skip to content

Commit

Permalink
c/r: prctl: drop VMA flags test on PR_SET_MM_ stack data assignment
Browse files Browse the repository at this point in the history
In commit b764375 ("procfs: mark thread stack correctly in
proc/<pid>/maps") the stack allocated via clone() is marked in
/proc/<pid>/maps as [stack:%d] thus it might be out of the former
mm->start_stack/end_stack values (and even has some custom VMA flags
set).

So to be able to restore mm->start_stack/end_stack drop vma flags test,
but still require the underlying VMA to exist.

As always note this feature is under CONFIG_CHECKPOINT_RESTORE and
requires CAP_SYS_RESOURCE to be granted.

Signed-off-by: Cyrill Gorcunov <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Acked-by: Kees Cook <[email protected]>
Cc: Pavel Emelyanov <[email protected]>
Cc: Serge Hallyn <[email protected]>
Cc: KAMEZAWA Hiroyuki <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
cyrillos authored and torvalds committed Jun 7, 2012
1 parent 300f786 commit 736f24d
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions kernel/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -1786,14 +1786,6 @@ SYSCALL_DEFINE1(umask, int, mask)
}

#ifdef CONFIG_CHECKPOINT_RESTORE
static bool vma_flags_mismatch(struct vm_area_struct *vma,
unsigned long required,
unsigned long banned)
{
return (vma->vm_flags & required) != required ||
(vma->vm_flags & banned);
}

static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
{
struct vm_area_struct *vma;
Expand Down Expand Up @@ -1931,12 +1923,6 @@ static int prctl_set_mm(int opt, unsigned long addr,
error = -EFAULT;
goto out;
}
#ifdef CONFIG_STACK_GROWSUP
if (vma_flags_mismatch(vma, VM_READ | VM_WRITE | VM_GROWSUP, 0))
#else
if (vma_flags_mismatch(vma, VM_READ | VM_WRITE | VM_GROWSDOWN, 0))
#endif
goto out;
if (opt == PR_SET_MM_START_STACK)
mm->start_stack = addr;
else if (opt == PR_SET_MM_ARG_START)
Expand Down

0 comments on commit 736f24d

Please sign in to comment.