Commit 52b3694157e3aa6df871e283115652ec6f2d31e0

Authored by Amnon Shiloh
Committed by Linus Torvalds
1 parent 22145aa1f6

kernel/sys.c: make prctl(PR_SET_MM) generally available

The purpose of this patch is to allow privileged processes to set
their own per-memory memory-region fields:

      start_code, end_code, start_data, end_data, start_brk, brk,
      start_stack, arg_start, arg_end, env_start, env_end.

This functionality is needed by any application or package that needs to
reconstruct Linux processes, that is, to start them in any way other than
by means of an "execve()" from an executable file.  This includes:

1. Restoring processes from a checkpoint-file (by all potential
   user-level checkpointing packages, not only CRIU's).
2. Restarting processes on another node after process migration.
3. Starting duplicated copies of a running process (for reliability
   and high-availablity).
4. Starting a process from an executable format that is not supported
   by Linux, thus requiring a "manual execve" by a user-level utility.
5. Similarly, starting a process from a networked and/or crypted
   executable that, for confidentiality, licensing or other reasons,
   may not be written to the local file-systems.

The code that does that was already included in the Linux kernel by the
CRIU group, in the form of "prctl(PR_SET_MM)", but prior to this was
enclosed within their private "#ifdef CONFIG_CHECKPOINT_RESTORE", which is
normally disabled.  The patch removes those ifdefs.

Signed-off-by: Amnon Shiloh <u3557@miso.sublimeip.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 2 additions and 8 deletions Side-by-side Diff

... ... @@ -1857,7 +1857,6 @@
1857 1857 return mask;
1858 1858 }
1859 1859  
1860   -#ifdef CONFIG_CHECKPOINT_RESTORE
1861 1860 static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
1862 1861 {
1863 1862 struct fd exe;
1864 1863  
... ... @@ -2051,17 +2050,12 @@
2051 2050 return error;
2052 2051 }
2053 2052  
  2053 +#ifdef CONFIG_CHECKPOINT_RESTORE
2054 2054 static int prctl_get_tid_address(struct task_struct *me, int __user **tid_addr)
2055 2055 {
2056 2056 return put_user(me->clear_child_tid, tid_addr);
2057 2057 }
2058   -
2059   -#else /* CONFIG_CHECKPOINT_RESTORE */
2060   -static int prctl_set_mm(int opt, unsigned long addr,
2061   - unsigned long arg4, unsigned long arg5)
2062   -{
2063   - return -EINVAL;
2064   -}
  2058 +#else
2065 2059 static int prctl_get_tid_address(struct task_struct *me, int __user **tid_addr)
2066 2060 {
2067 2061 return -EINVAL;