aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sys.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sys.c')
-rw-r--r--kernel/sys.c288
1 files changed, 144 insertions, 144 deletions
diff --git a/kernel/sys.c b/kernel/sys.c
index 265b37690421..840cfdad7bfc 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -47,6 +47,7 @@
47#include <linux/syscalls.h> 47#include <linux/syscalls.h>
48#include <linux/kprobes.h> 48#include <linux/kprobes.h>
49#include <linux/user_namespace.h> 49#include <linux/user_namespace.h>
50#include <linux/binfmts.h>
50 51
51#include <linux/kmsg_dump.h> 52#include <linux/kmsg_dump.h>
52/* Move somewhere else to avoid recompiling? */ 53/* Move somewhere else to avoid recompiling? */
@@ -2012,160 +2013,159 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
2012 2013
2013 error = 0; 2014 error = 0;
2014 switch (option) { 2015 switch (option) {
2015 case PR_SET_PDEATHSIG: 2016 case PR_SET_PDEATHSIG:
2016 if (!valid_signal(arg2)) { 2017 if (!valid_signal(arg2)) {
2017 error = -EINVAL; 2018 error = -EINVAL;
2018 break;
2019 }
2020 me->pdeath_signal = arg2;
2021 break;
2022 case PR_GET_PDEATHSIG:
2023 error = put_user(me->pdeath_signal, (int __user *)arg2);
2024 break;
2025 case PR_GET_DUMPABLE:
2026 error = get_dumpable(me->mm);
2027 break; 2019 break;
2028 case PR_SET_DUMPABLE: 2020 }
2029 if (arg2 < 0 || arg2 > 1) { 2021 me->pdeath_signal = arg2;
2030 error = -EINVAL; 2022 break;
2031 break; 2023 case PR_GET_PDEATHSIG:
2032 } 2024 error = put_user(me->pdeath_signal, (int __user *)arg2);
2033 set_dumpable(me->mm, arg2); 2025 break;
2026 case PR_GET_DUMPABLE:
2027 error = get_dumpable(me->mm);
2028 break;
2029 case PR_SET_DUMPABLE:
2030 if (arg2 != SUID_DUMP_DISABLE && arg2 != SUID_DUMP_USER) {
2031 error = -EINVAL;
2034 break; 2032 break;
2033 }
2034 set_dumpable(me->mm, arg2);
2035 break;
2035 2036
2036 case PR_SET_UNALIGN: 2037 case PR_SET_UNALIGN:
2037 error = SET_UNALIGN_CTL(me, arg2); 2038 error = SET_UNALIGN_CTL(me, arg2);
2038 break; 2039 break;
2039 case PR_GET_UNALIGN: 2040 case PR_GET_UNALIGN:
2040 error = GET_UNALIGN_CTL(me, arg2); 2041 error = GET_UNALIGN_CTL(me, arg2);
2041 break; 2042 break;
2042 case PR_SET_FPEMU: 2043 case PR_SET_FPEMU:
2043 error = SET_FPEMU_CTL(me, arg2); 2044 error = SET_FPEMU_CTL(me, arg2);
2044 break; 2045 break;
2045 case PR_GET_FPEMU: 2046 case PR_GET_FPEMU:
2046 error = GET_FPEMU_CTL(me, arg2); 2047 error = GET_FPEMU_CTL(me, arg2);
2047 break; 2048 break;
2048 case PR_SET_FPEXC: 2049 case PR_SET_FPEXC:
2049 error = SET_FPEXC_CTL(me, arg2); 2050 error = SET_FPEXC_CTL(me, arg2);
2050 break; 2051 break;
2051 case PR_GET_FPEXC: 2052 case PR_GET_FPEXC:
2052 error = GET_FPEXC_CTL(me, arg2); 2053 error = GET_FPEXC_CTL(me, arg2);
2053 break; 2054 break;
2054 case PR_GET_TIMING: 2055 case PR_GET_TIMING:
2055 error = PR_TIMING_STATISTICAL; 2056 error = PR_TIMING_STATISTICAL;
2056 break; 2057 break;
2057 case PR_SET_TIMING: 2058 case PR_SET_TIMING:
2058 if (arg2 != PR_TIMING_STATISTICAL) 2059 if (arg2 != PR_TIMING_STATISTICAL)
2059 error = -EINVAL; 2060 error = -EINVAL;
2060 break; 2061 break;
2061 case PR_SET_NAME: 2062 case PR_SET_NAME:
2062 comm[sizeof(me->comm)-1] = 0; 2063 comm[sizeof(me->comm) - 1] = 0;
2063 if (strncpy_from_user(comm, (char __user *)arg2, 2064 if (strncpy_from_user(comm, (char __user *)arg2,
2064 sizeof(me->comm) - 1) < 0) 2065 sizeof(me->comm) - 1) < 0)
2065 return -EFAULT; 2066 return -EFAULT;
2066 set_task_comm(me, comm); 2067 set_task_comm(me, comm);
2067 proc_comm_connector(me); 2068 proc_comm_connector(me);
2068 break; 2069 break;
2069 case PR_GET_NAME: 2070 case PR_GET_NAME:
2070 get_task_comm(comm, me); 2071 get_task_comm(comm, me);
2071 if (copy_to_user((char __user *)arg2, comm, 2072 if (copy_to_user((char __user *)arg2, comm, sizeof(comm)))
2072 sizeof(comm))) 2073 return -EFAULT;
2073 return -EFAULT; 2074 break;
2074 break; 2075 case PR_GET_ENDIAN:
2075 case PR_GET_ENDIAN: 2076 error = GET_ENDIAN(me, arg2);
2076 error = GET_ENDIAN(me, arg2); 2077 break;
2077 break; 2078 case PR_SET_ENDIAN:
2078 case PR_SET_ENDIAN: 2079 error = SET_ENDIAN(me, arg2);
2079 error = SET_ENDIAN(me, arg2); 2080 break;
2080 break; 2081 case PR_GET_SECCOMP:
2081 case PR_GET_SECCOMP: 2082 error = prctl_get_seccomp();
2082 error = prctl_get_seccomp(); 2083 break;
2083 break; 2084 case PR_SET_SECCOMP:
2084 case PR_SET_SECCOMP: 2085 error = prctl_set_seccomp(arg2, (char __user *)arg3);
2085 error = prctl_set_seccomp(arg2, (char __user *)arg3); 2086 break;
2086 break; 2087 case PR_GET_TSC:
2087 case PR_GET_TSC: 2088 error = GET_TSC_CTL(arg2);
2088 error = GET_TSC_CTL(arg2); 2089 break;
2089 break; 2090 case PR_SET_TSC:
2090 case PR_SET_TSC: 2091 error = SET_TSC_CTL(arg2);
2091 error = SET_TSC_CTL(arg2); 2092 break;
2092 break; 2093 case PR_TASK_PERF_EVENTS_DISABLE:
2093 case PR_TASK_PERF_EVENTS_DISABLE: 2094 error = perf_event_task_disable();
2094 error = perf_event_task_disable(); 2095 break;
2095 break; 2096 case PR_TASK_PERF_EVENTS_ENABLE:
2096 case PR_TASK_PERF_EVENTS_ENABLE: 2097 error = perf_event_task_enable();
2097 error = perf_event_task_enable(); 2098 break;
2098 break; 2099 case PR_GET_TIMERSLACK:
2099 case PR_GET_TIMERSLACK: 2100 error = current->timer_slack_ns;
2100 error = current->timer_slack_ns; 2101 break;
2101 break; 2102 case PR_SET_TIMERSLACK:
2102 case PR_SET_TIMERSLACK: 2103 if (arg2 <= 0)
2103 if (arg2 <= 0) 2104 current->timer_slack_ns =
2104 current->timer_slack_ns =
2105 current->default_timer_slack_ns; 2105 current->default_timer_slack_ns;
2106 else 2106 else
2107 current->timer_slack_ns = arg2; 2107 current->timer_slack_ns = arg2;
2108 break; 2108 break;
2109 case PR_MCE_KILL: 2109 case PR_MCE_KILL:
2110 if (arg4 | arg5) 2110 if (arg4 | arg5)
2111 return -EINVAL; 2111 return -EINVAL;
2112 switch (arg2) { 2112 switch (arg2) {
2113 case PR_MCE_KILL_CLEAR: 2113 case PR_MCE_KILL_CLEAR:
2114 if (arg3 != 0) 2114 if (arg3 != 0)
2115 return -EINVAL;
2116 current->flags &= ~PF_MCE_PROCESS;
2117 break;
2118 case PR_MCE_KILL_SET:
2119 current->flags |= PF_MCE_PROCESS;
2120 if (arg3 == PR_MCE_KILL_EARLY)
2121 current->flags |= PF_MCE_EARLY;
2122 else if (arg3 == PR_MCE_KILL_LATE)
2123 current->flags &= ~PF_MCE_EARLY;
2124 else if (arg3 == PR_MCE_KILL_DEFAULT)
2125 current->flags &=
2126 ~(PF_MCE_EARLY|PF_MCE_PROCESS);
2127 else
2128 return -EINVAL;
2129 break;
2130 default:
2131 return -EINVAL; 2115 return -EINVAL;
2132 } 2116 current->flags &= ~PF_MCE_PROCESS;
2133 break; 2117 break;
2134 case PR_MCE_KILL_GET: 2118 case PR_MCE_KILL_SET:
2135 if (arg2 | arg3 | arg4 | arg5) 2119 current->flags |= PF_MCE_PROCESS;
2136 return -EINVAL; 2120 if (arg3 == PR_MCE_KILL_EARLY)
2137 if (current->flags & PF_MCE_PROCESS) 2121 current->flags |= PF_MCE_EARLY;
2138 error = (current->flags & PF_MCE_EARLY) ? 2122 else if (arg3 == PR_MCE_KILL_LATE)
2139 PR_MCE_KILL_EARLY : PR_MCE_KILL_LATE; 2123 current->flags &= ~PF_MCE_EARLY;
2124 else if (arg3 == PR_MCE_KILL_DEFAULT)
2125 current->flags &=
2126 ~(PF_MCE_EARLY|PF_MCE_PROCESS);
2140 else 2127 else
2141 error = PR_MCE_KILL_DEFAULT;
2142 break;
2143 case PR_SET_MM:
2144 error = prctl_set_mm(arg2, arg3, arg4, arg5);
2145 break;
2146 case PR_GET_TID_ADDRESS:
2147 error = prctl_get_tid_address(me, (int __user **)arg2);
2148 break;
2149 case PR_SET_CHILD_SUBREAPER:
2150 me->signal->is_child_subreaper = !!arg2;
2151 break;
2152 case PR_GET_CHILD_SUBREAPER:
2153 error = put_user(me->signal->is_child_subreaper,
2154 (int __user *) arg2);
2155 break;
2156 case PR_SET_NO_NEW_PRIVS:
2157 if (arg2 != 1 || arg3 || arg4 || arg5)
2158 return -EINVAL; 2128 return -EINVAL;
2159
2160 current->no_new_privs = 1;
2161 break; 2129 break;
2162 case PR_GET_NO_NEW_PRIVS:
2163 if (arg2 || arg3 || arg4 || arg5)
2164 return -EINVAL;
2165 return current->no_new_privs ? 1 : 0;
2166 default: 2130 default:
2167 error = -EINVAL; 2131 return -EINVAL;
2168 break; 2132 }
2133 break;
2134 case PR_MCE_KILL_GET:
2135 if (arg2 | arg3 | arg4 | arg5)
2136 return -EINVAL;
2137 if (current->flags & PF_MCE_PROCESS)
2138 error = (current->flags & PF_MCE_EARLY) ?
2139 PR_MCE_KILL_EARLY : PR_MCE_KILL_LATE;
2140 else
2141 error = PR_MCE_KILL_DEFAULT;
2142 break;
2143 case PR_SET_MM:
2144 error = prctl_set_mm(arg2, arg3, arg4, arg5);
2145 break;
2146 case PR_GET_TID_ADDRESS:
2147 error = prctl_get_tid_address(me, (int __user **)arg2);
2148 break;
2149 case PR_SET_CHILD_SUBREAPER:
2150 me->signal->is_child_subreaper = !!arg2;
2151 break;
2152 case PR_GET_CHILD_SUBREAPER:
2153 error = put_user(me->signal->is_child_subreaper,
2154 (int __user *)arg2);
2155 break;
2156 case PR_SET_NO_NEW_PRIVS:
2157 if (arg2 != 1 || arg3 || arg4 || arg5)
2158 return -EINVAL;
2159
2160 current->no_new_privs = 1;
2161 break;
2162 case PR_GET_NO_NEW_PRIVS:
2163 if (arg2 || arg3 || arg4 || arg5)
2164 return -EINVAL;
2165 return current->no_new_privs ? 1 : 0;
2166 default:
2167 error = -EINVAL;
2168 break;
2169 } 2169 }
2170 return error; 2170 return error;
2171} 2171}