Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

c/r: prctl: drop VMA flags test on PR_SET_MM_ stack data assignment

In commit b76437579d13 ("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 <gorcunov@openvz.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Pavel Emelyanov <xemul@parallels.com>
Cc: Serge Hallyn <serge.hallyn@canonical.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Cyrill Gorcunov and committed by
Linus Torvalds
736f24d5 300f786b

-14
-14
kernel/sys.c
··· 1786 1786 } 1787 1787 1788 1788 #ifdef CONFIG_CHECKPOINT_RESTORE 1789 - static bool vma_flags_mismatch(struct vm_area_struct *vma, 1790 - unsigned long required, 1791 - unsigned long banned) 1792 - { 1793 - return (vma->vm_flags & required) != required || 1794 - (vma->vm_flags & banned); 1795 - } 1796 - 1797 1789 static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd) 1798 1790 { 1799 1791 struct vm_area_struct *vma; ··· 1923 1931 error = -EFAULT; 1924 1932 goto out; 1925 1933 } 1926 - #ifdef CONFIG_STACK_GROWSUP 1927 - if (vma_flags_mismatch(vma, VM_READ | VM_WRITE | VM_GROWSUP, 0)) 1928 - #else 1929 - if (vma_flags_mismatch(vma, VM_READ | VM_WRITE | VM_GROWSDOWN, 0)) 1930 - #endif 1931 - goto out; 1932 1934 if (opt == PR_SET_MM_START_STACK) 1933 1935 mm->start_stack = addr; 1934 1936 else if (opt == PR_SET_MM_ARG_START)