diff options
Diffstat (limited to 'kernel/sys.c')
-rw-r--r-- | kernel/sys.c | 77 |
1 files changed, 70 insertions, 7 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index 26a6b73a6b85..8298878f4f71 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/task_io_accounting_ops.h> | 33 | #include <linux/task_io_accounting_ops.h> |
34 | #include <linux/seccomp.h> | 34 | #include <linux/seccomp.h> |
35 | #include <linux/cpu.h> | 35 | #include <linux/cpu.h> |
36 | #include <linux/personality.h> | ||
36 | #include <linux/ptrace.h> | 37 | #include <linux/ptrace.h> |
37 | #include <linux/fs_struct.h> | 38 | #include <linux/fs_struct.h> |
38 | 39 | ||
@@ -222,6 +223,7 @@ SYSCALL_DEFINE2(getpriority, int, which, int, who) | |||
222 | if (which > PRIO_USER || which < PRIO_PROCESS) | 223 | if (which > PRIO_USER || which < PRIO_PROCESS) |
223 | return -EINVAL; | 224 | return -EINVAL; |
224 | 225 | ||
226 | rcu_read_lock(); | ||
225 | read_lock(&tasklist_lock); | 227 | read_lock(&tasklist_lock); |
226 | switch (which) { | 228 | switch (which) { |
227 | case PRIO_PROCESS: | 229 | case PRIO_PROCESS: |
@@ -267,6 +269,7 @@ SYSCALL_DEFINE2(getpriority, int, which, int, who) | |||
267 | } | 269 | } |
268 | out_unlock: | 270 | out_unlock: |
269 | read_unlock(&tasklist_lock); | 271 | read_unlock(&tasklist_lock); |
272 | rcu_read_unlock(); | ||
270 | 273 | ||
271 | return retval; | 274 | return retval; |
272 | } | 275 | } |
@@ -569,13 +572,7 @@ static int set_user(struct cred *new) | |||
569 | if (!new_user) | 572 | if (!new_user) |
570 | return -EAGAIN; | 573 | return -EAGAIN; |
571 | 574 | ||
572 | if (!task_can_switch_user(new_user, current)) { | 575 | if (atomic_read(&new_user->processes) >= rlimit(RLIMIT_NPROC) && |
573 | free_uid(new_user); | ||
574 | return -EINVAL; | ||
575 | } | ||
576 | |||
577 | if (atomic_read(&new_user->processes) >= | ||
578 | current->signal->rlim[RLIMIT_NPROC].rlim_cur && | ||
579 | new_user != INIT_USER) { | 576 | new_user != INIT_USER) { |
580 | free_uid(new_user); | 577 | free_uid(new_user); |
581 | return -EAGAIN; | 578 | return -EAGAIN; |
@@ -1118,6 +1115,15 @@ out: | |||
1118 | 1115 | ||
1119 | DECLARE_RWSEM(uts_sem); | 1116 | DECLARE_RWSEM(uts_sem); |
1120 | 1117 | ||
1118 | #ifdef COMPAT_UTS_MACHINE | ||
1119 | #define override_architecture(name) \ | ||
1120 | (current->personality == PER_LINUX32 && \ | ||
1121 | copy_to_user(name->machine, COMPAT_UTS_MACHINE, \ | ||
1122 | sizeof(COMPAT_UTS_MACHINE))) | ||
1123 | #else | ||
1124 | #define override_architecture(name) 0 | ||
1125 | #endif | ||
1126 | |||
1121 | SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name) | 1127 | SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name) |
1122 | { | 1128 | { |
1123 | int errno = 0; | 1129 | int errno = 0; |
@@ -1126,9 +1132,66 @@ SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name) | |||
1126 | if (copy_to_user(name, utsname(), sizeof *name)) | 1132 | if (copy_to_user(name, utsname(), sizeof *name)) |
1127 | errno = -EFAULT; | 1133 | errno = -EFAULT; |
1128 | up_read(&uts_sem); | 1134 | up_read(&uts_sem); |
1135 | |||
1136 | if (!errno && override_architecture(name)) | ||
1137 | errno = -EFAULT; | ||
1129 | return errno; | 1138 | return errno; |
1130 | } | 1139 | } |
1131 | 1140 | ||
1141 | #ifdef __ARCH_WANT_SYS_OLD_UNAME | ||
1142 | /* | ||
1143 | * Old cruft | ||
1144 | */ | ||
1145 | SYSCALL_DEFINE1(uname, struct old_utsname __user *, name) | ||
1146 | { | ||
1147 | int error = 0; | ||
1148 | |||
1149 | if (!name) | ||
1150 | return -EFAULT; | ||
1151 | |||
1152 | down_read(&uts_sem); | ||
1153 | if (copy_to_user(name, utsname(), sizeof(*name))) | ||
1154 | error = -EFAULT; | ||
1155 | up_read(&uts_sem); | ||
1156 | |||
1157 | if (!error && override_architecture(name)) | ||
1158 | error = -EFAULT; | ||
1159 | return error; | ||
1160 | } | ||
1161 | |||
1162 | SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name) | ||
1163 | { | ||
1164 | int error; | ||
1165 | |||
1166 | if (!name) | ||
1167 | return -EFAULT; | ||
1168 | if (!access_ok(VERIFY_WRITE, name, sizeof(struct oldold_utsname))) | ||
1169 | return -EFAULT; | ||
1170 | |||
1171 | down_read(&uts_sem); | ||
1172 | error = __copy_to_user(&name->sysname, &utsname()->sysname, | ||
1173 | __OLD_UTS_LEN); | ||
1174 | error |= __put_user(0, name->sysname + __OLD_UTS_LEN); | ||
1175 | error |= __copy_to_user(&name->nodename, &utsname()->nodename, | ||
1176 | __OLD_UTS_LEN); | ||
1177 | error |= __put_user(0, name->nodename + __OLD_UTS_LEN); | ||
1178 | error |= __copy_to_user(&name->release, &utsname()->release, | ||
1179 | __OLD_UTS_LEN); | ||
1180 | error |= __put_user(0, name->release + __OLD_UTS_LEN); | ||
1181 | error |= __copy_to_user(&name->version, &utsname()->version, | ||
1182 | __OLD_UTS_LEN); | ||
1183 | error |= __put_user(0, name->version + __OLD_UTS_LEN); | ||
1184 | error |= __copy_to_user(&name->machine, &utsname()->machine, | ||
1185 | __OLD_UTS_LEN); | ||
1186 | error |= __put_user(0, name->machine + __OLD_UTS_LEN); | ||
1187 | up_read(&uts_sem); | ||
1188 | |||
1189 | if (!error && override_architecture(name)) | ||
1190 | error = -EFAULT; | ||
1191 | return error ? -EFAULT : 0; | ||
1192 | } | ||
1193 | #endif | ||
1194 | |||
1132 | SYSCALL_DEFINE2(sethostname, char __user *, name, int, len) | 1195 | SYSCALL_DEFINE2(sethostname, char __user *, name, int, len) |
1133 | { | 1196 | { |
1134 | int errno; | 1197 | int errno; |