aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-09-14 20:37:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-14 20:37:26 -0400
commitcc73fee0bae2d66594d1fa2df92bbd783aa98e04 (patch)
treed1e7fe7f76cae4cbc941fc3bb43a46d237a9df77
parente7cdb60fd28b252f1c15a0e50f79a01906124915 (diff)
parentaaed2dd8a31359e5767ee099ecbb078d55be4d29 (diff)
Merge branch 'work.ipc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull ipc compat cleanup and 64-bit time_t from Al Viro: "IPC copyin/copyout sanitizing, including 64bit time_t work from Deepa Dinamani" * 'work.ipc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: utimes: Make utimes y2038 safe ipc: shm: Make shmid_kernel timestamps y2038 safe ipc: sem: Make sem_array timestamps y2038 safe ipc: msg: Make msg_queue timestamps y2038 safe ipc: mqueue: Replace timespec with timespec64 ipc: Make sys_semtimedop() y2038 safe get rid of SYSVIPC_COMPAT on ia64 semtimedop(): move compat to native shmat(2): move compat to native msgrcv(2), msgsnd(2): move compat to native ipc(2): move compat to native ipc: make use of compat ipc_perm helpers semctl(): move compat to native semctl(): separate all layout-dependent copyin/copyout msgctl(): move compat to native msgctl(): split the actual work from copyin/copyout ipc: move compat shmctl to native shmctl: split the work from copyin/copyout
-rw-r--r--arch/ia64/Kconfig.debug5
-rw-r--r--fs/utimes.c23
-rw-r--r--include/linux/audit.h6
-rw-r--r--include/linux/compat.h9
-rw-r--r--include/linux/msg.h15
-rw-r--r--include/linux/sem.h3
-rw-r--r--include/linux/shm.h6
-rw-r--r--include/linux/time.h2
-rw-r--r--init/initramfs.c2
-rw-r--r--ipc/compat.c740
-rw-r--r--ipc/mqueue.c28
-rw-r--r--ipc/msg.c366
-rw-r--r--ipc/sem.c344
-rw-r--r--ipc/shm.c533
-rw-r--r--ipc/syscall.c90
-rw-r--r--ipc/util.h30
-rw-r--r--kernel/audit.h2
-rw-r--r--kernel/auditsc.c12
-rw-r--r--kernel/compat.c23
19 files changed, 1044 insertions, 1195 deletions
diff --git a/arch/ia64/Kconfig.debug b/arch/ia64/Kconfig.debug
index de9d507ba0fd..4763887ba368 100644
--- a/arch/ia64/Kconfig.debug
+++ b/arch/ia64/Kconfig.debug
@@ -56,9 +56,4 @@ config IA64_DEBUG_IRQ
56 and restore instructions. It's useful for tracking down spinlock 56 and restore instructions. It's useful for tracking down spinlock
57 problems, but slow! If you're unsure, select N. 57 problems, but slow! If you're unsure, select N.
58 58
59config SYSVIPC_COMPAT
60 bool
61 depends on COMPAT && SYSVIPC
62 default y
63
64endmenu 59endmenu
diff --git a/fs/utimes.c b/fs/utimes.c
index 6571d8c848a0..51edb9f9507c 100644
--- a/fs/utimes.c
+++ b/fs/utimes.c
@@ -22,7 +22,7 @@
22 */ 22 */
23SYSCALL_DEFINE2(utime, char __user *, filename, struct utimbuf __user *, times) 23SYSCALL_DEFINE2(utime, char __user *, filename, struct utimbuf __user *, times)
24{ 24{
25 struct timespec tv[2]; 25 struct timespec64 tv[2];
26 26
27 if (times) { 27 if (times) {
28 if (get_user(tv[0].tv_sec, &times->actime) || 28 if (get_user(tv[0].tv_sec, &times->actime) ||
@@ -44,7 +44,7 @@ static bool nsec_valid(long nsec)
44 return nsec >= 0 && nsec <= 999999999; 44 return nsec >= 0 && nsec <= 999999999;
45} 45}
46 46
47static int utimes_common(const struct path *path, struct timespec *times) 47static int utimes_common(const struct path *path, struct timespec64 *times)
48{ 48{
49 int error; 49 int error;
50 struct iattr newattrs; 50 struct iattr newattrs;
@@ -115,7 +115,7 @@ out:
115 * must be owner or have write permission. 115 * must be owner or have write permission.
116 * Else, update from *times, must be owner or super user. 116 * Else, update from *times, must be owner or super user.
117 */ 117 */
118long do_utimes(int dfd, const char __user *filename, struct timespec *times, 118long do_utimes(int dfd, const char __user *filename, struct timespec64 *times,
119 int flags) 119 int flags)
120{ 120{
121 int error = -EINVAL; 121 int error = -EINVAL;
@@ -167,10 +167,11 @@ out:
167SYSCALL_DEFINE4(utimensat, int, dfd, const char __user *, filename, 167SYSCALL_DEFINE4(utimensat, int, dfd, const char __user *, filename,
168 struct timespec __user *, utimes, int, flags) 168 struct timespec __user *, utimes, int, flags)
169{ 169{
170 struct timespec tstimes[2]; 170 struct timespec64 tstimes[2];
171 171
172 if (utimes) { 172 if (utimes) {
173 if (copy_from_user(&tstimes, utimes, sizeof(tstimes))) 173 if ((get_timespec64(&tstimes[0], &utimes[0]) ||
174 get_timespec64(&tstimes[1], &utimes[1])))
174 return -EFAULT; 175 return -EFAULT;
175 176
176 /* Nothing to do, we must not even check the path. */ 177 /* Nothing to do, we must not even check the path. */
@@ -186,7 +187,7 @@ SYSCALL_DEFINE3(futimesat, int, dfd, const char __user *, filename,
186 struct timeval __user *, utimes) 187 struct timeval __user *, utimes)
187{ 188{
188 struct timeval times[2]; 189 struct timeval times[2];
189 struct timespec tstimes[2]; 190 struct timespec64 tstimes[2];
190 191
191 if (utimes) { 192 if (utimes) {
192 if (copy_from_user(&times, utimes, sizeof(times))) 193 if (copy_from_user(&times, utimes, sizeof(times)))
@@ -224,7 +225,7 @@ SYSCALL_DEFINE2(utimes, char __user *, filename,
224COMPAT_SYSCALL_DEFINE2(utime, const char __user *, filename, 225COMPAT_SYSCALL_DEFINE2(utime, const char __user *, filename,
225 struct compat_utimbuf __user *, t) 226 struct compat_utimbuf __user *, t)
226{ 227{
227 struct timespec tv[2]; 228 struct timespec64 tv[2];
228 229
229 if (t) { 230 if (t) {
230 if (get_user(tv[0].tv_sec, &t->actime) || 231 if (get_user(tv[0].tv_sec, &t->actime) ||
@@ -238,11 +239,11 @@ COMPAT_SYSCALL_DEFINE2(utime, const char __user *, filename,
238 239
239COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filename, struct compat_timespec __user *, t, int, flags) 240COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filename, struct compat_timespec __user *, t, int, flags)
240{ 241{
241 struct timespec tv[2]; 242 struct timespec64 tv[2];
242 243
243 if (t) { 244 if (t) {
244 if (compat_get_timespec(&tv[0], &t[0]) || 245 if (compat_get_timespec64(&tv[0], &t[0]) ||
245 compat_get_timespec(&tv[1], &t[1])) 246 compat_get_timespec64(&tv[1], &t[1]))
246 return -EFAULT; 247 return -EFAULT;
247 248
248 if (tv[0].tv_nsec == UTIME_OMIT && tv[1].tv_nsec == UTIME_OMIT) 249 if (tv[0].tv_nsec == UTIME_OMIT && tv[1].tv_nsec == UTIME_OMIT)
@@ -253,7 +254,7 @@ COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filena
253 254
254COMPAT_SYSCALL_DEFINE3(futimesat, unsigned int, dfd, const char __user *, filename, struct compat_timeval __user *, t) 255COMPAT_SYSCALL_DEFINE3(futimesat, unsigned int, dfd, const char __user *, filename, struct compat_timeval __user *, t)
255{ 256{
256 struct timespec tv[2]; 257 struct timespec64 tv[2];
257 258
258 if (t) { 259 if (t) {
259 if (get_user(tv[0].tv_sec, &t[0].tv_sec) || 260 if (get_user(tv[0].tv_sec, &t[0].tv_sec) ||
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 2150bdccfbab..74d4d4e8e3db 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -351,7 +351,7 @@ extern int __audit_socketcall(int nargs, unsigned long *args);
351extern int __audit_sockaddr(int len, void *addr); 351extern int __audit_sockaddr(int len, void *addr);
352extern void __audit_fd_pair(int fd1, int fd2); 352extern void __audit_fd_pair(int fd1, int fd2);
353extern void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr); 353extern void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr);
354extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout); 354extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec64 *abs_timeout);
355extern void __audit_mq_notify(mqd_t mqdes, const struct sigevent *notification); 355extern void __audit_mq_notify(mqd_t mqdes, const struct sigevent *notification);
356extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat); 356extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat);
357extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm, 357extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm,
@@ -412,7 +412,7 @@ static inline void audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr)
412 if (unlikely(!audit_dummy_context())) 412 if (unlikely(!audit_dummy_context()))
413 __audit_mq_open(oflag, mode, attr); 413 __audit_mq_open(oflag, mode, attr);
414} 414}
415static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout) 415static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec64 *abs_timeout)
416{ 416{
417 if (unlikely(!audit_dummy_context())) 417 if (unlikely(!audit_dummy_context()))
418 __audit_mq_sendrecv(mqdes, msg_len, msg_prio, abs_timeout); 418 __audit_mq_sendrecv(mqdes, msg_len, msg_prio, abs_timeout);
@@ -549,7 +549,7 @@ static inline void audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr)
549{ } 549{ }
550static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, 550static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len,
551 unsigned int msg_prio, 551 unsigned int msg_prio,
552 const struct timespec *abs_timeout) 552 const struct timespec64 *abs_timeout)
553{ } 553{ }
554static inline void audit_mq_notify(mqd_t mqdes, 554static inline void audit_mq_notify(mqd_t mqdes,
555 const struct sigevent *notification) 555 const struct sigevent *notification)
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 3fc433303d7a..a5619de3437d 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -171,15 +171,6 @@ extern int get_compat_itimerspec64(struct itimerspec64 *its,
171extern int put_compat_itimerspec64(const struct itimerspec64 *its, 171extern int put_compat_itimerspec64(const struct itimerspec64 *its,
172 struct compat_itimerspec __user *uits); 172 struct compat_itimerspec __user *uits);
173 173
174/*
175 * This function convert a timespec if necessary and returns a *user
176 * space* pointer. If no conversion is necessary, it returns the
177 * initial pointer. NULL is a legitimate argument and will always
178 * output NULL.
179 */
180extern int compat_convert_timespec(struct timespec __user **,
181 const void __user *);
182
183struct compat_iovec { 174struct compat_iovec {
184 compat_uptr_t iov_base; 175 compat_uptr_t iov_base;
185 compat_size_t iov_len; 176 compat_size_t iov_len;
diff --git a/include/linux/msg.h b/include/linux/msg.h
index a001305f5a79..81263fe3f9dc 100644
--- a/include/linux/msg.h
+++ b/include/linux/msg.h
@@ -2,6 +2,7 @@
2#define _LINUX_MSG_H 2#define _LINUX_MSG_H
3 3
4#include <linux/list.h> 4#include <linux/list.h>