diff options
Diffstat (limited to 'kernel/sys.c')
| -rw-r--r-- | kernel/sys.c | 71 |
1 files changed, 69 insertions, 2 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index 877fe4f8e05e..7cb426a58965 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
| @@ -33,8 +33,10 @@ | |||
| 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> |
| 39 | #include <linux/gfp.h> | ||
| 38 | 40 | ||
| 39 | #include <linux/compat.h> | 41 | #include <linux/compat.h> |
| 40 | #include <linux/syscalls.h> | 42 | #include <linux/syscalls.h> |
| @@ -571,8 +573,7 @@ static int set_user(struct cred *new) | |||
| 571 | if (!new_user) | 573 | if (!new_user) |
| 572 | return -EAGAIN; | 574 | return -EAGAIN; |
| 573 | 575 | ||
| 574 | if (atomic_read(&new_user->processes) >= | 576 | if (atomic_read(&new_user->processes) >= rlimit(RLIMIT_NPROC) && |
| 575 | current->signal->rlim[RLIMIT_NPROC].rlim_cur && | ||
| 576 | new_user != INIT_USER) { | 577 | new_user != INIT_USER) { |
| 577 | free_uid(new_user); | 578 | free_uid(new_user); |
| 578 | return -EAGAIN; | 579 | return -EAGAIN; |
| @@ -1115,6 +1116,15 @@ out: | |||
| 1115 | 1116 | ||
| 1116 | DECLARE_RWSEM(uts_sem); | 1117 | DECLARE_RWSEM(uts_sem); |
| 1117 | 1118 | ||
| 1119 | #ifdef COMPAT_UTS_MACHINE | ||
| 1120 | #define override_architecture(name) \ | ||
| 1121 | (personality(current->personality) == PER_LINUX32 && \ | ||
| 1122 | copy_to_user(name->machine, COMPAT_UTS_MACHINE, \ | ||
| 1123 | sizeof(COMPAT_UTS_MACHINE))) | ||
| 1124 | #else | ||
| 1125 | #define override_architecture(name) 0 | ||
| 1126 | #endif | ||
| 1127 | |||
| 1118 | SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name) | 1128 | SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name) |
| 1119 | { | 1129 | { |
| 1120 | int errno = 0; | 1130 | int errno = 0; |
| @@ -1123,9 +1133,66 @@ SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name) | |||
| 1123 | if (copy_to_user(name, utsname(), sizeof *name)) | 1133 | if (copy_to_user(name, utsname(), sizeof *name)) |
| 1124 | errno = -EFAULT; | 1134 | errno = -EFAULT; |
| 1125 | up_read(&uts_sem); | 1135 | up_read(&uts_sem); |
| 1136 | |||
| 1137 | if (!errno && override_architecture(name)) | ||
| 1138 | errno = -EFAULT; | ||
| 1126 | return errno; | 1139 | return errno; |
| 1127 | } | 1140 | } |
| 1128 | 1141 | ||
| 1142 | #ifdef __ARCH_WANT_SYS_OLD_UNAME | ||
| 1143 | /* | ||
| 1144 | * Old cruft | ||
| 1145 | */ | ||
| 1146 | SYSCALL_DEFINE1(uname, struct old_utsname __user *, name) | ||
| 1147 | { | ||
| 1148 | int error = 0; | ||
| 1149 | |||
| 1150 | if (!name) | ||
| 1151 | return -EFAULT; | ||
| 1152 | |||
| 1153 | down_read(&uts_sem); | ||
| 1154 | if (copy_to_user(name, utsname(), sizeof(*name))) | ||
| 1155 | error = -EFAULT; | ||
| 1156 | up_read(&uts_sem); | ||
| 1157 | |||
| 1158 | if (!error && override_architecture(name)) | ||
| 1159 | error = -EFAULT; | ||
| 1160 | return error; | ||
| 1161 | } | ||
| 1162 | |||
| 1163 | SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name) | ||
| 1164 | { | ||
| 1165 | int error; | ||
| 1166 | |||
| 1167 | if (!name) | ||
| 1168 | return -EFAULT; | ||
| 1169 | if (!access_ok(VERIFY_WRITE, name, sizeof(struct oldold_utsname))) | ||
| 1170 | return -EFAULT; | ||
| 1171 | |||
| 1172 | down_read(&uts_sem); | ||
| 1173 | error = __copy_to_user(&name->sysname, &utsname()->sysname, | ||
| 1174 | __OLD_UTS_LEN); | ||
| 1175 | error |= __put_user(0, name->sysname + __OLD_UTS_LEN); | ||
| 1176 | error |= __copy_to_user(&name->nodename, &utsname()->nodename, | ||
| 1177 | __OLD_UTS_LEN); | ||
| 1178 | error |= __put_user(0, name->nodename + __OLD_UTS_LEN); | ||
| 1179 | error |= __copy_to_user(&name->release, &utsname()->release, | ||
| 1180 | __OLD_UTS_LEN); | ||
| 1181 | error |= __put_user(0, name->release + __OLD_UTS_LEN); | ||
| 1182 | error |= __copy_to_user(&name->version, &utsname()->version, | ||
| 1183 | __OLD_UTS_LEN); | ||
| 1184 | error |= __put_user(0, name->version + __OLD_UTS_LEN); | ||
| 1185 | error |= __copy_to_user(&name->machine, &utsname()->machine, | ||
| 1186 | __OLD_UTS_LEN); | ||
| 1187 | error |= __put_user(0, name->machine + __OLD_UTS_LEN); | ||
| 1188 | up_read(&uts_sem); | ||
| 1189 | |||
| 1190 | if (!error && override_architecture(name)) | ||
| 1191 | error = -EFAULT; | ||
| 1192 | return error ? -EFAULT : 0; | ||
| 1193 | } | ||
| 1194 | #endif | ||
| 1195 | |||
| 1129 | SYSCALL_DEFINE2(sethostname, char __user *, name, int, len) | 1196 | SYSCALL_DEFINE2(sethostname, char __user *, name, int, len) |
| 1130 | { | 1197 | { |
| 1131 | int errno; | 1198 | int errno; |
