ipc: fix regressions from y2038 patches
These are two regression fixes for bugs that got introduced during the system call rework that went into linux-5.1 but only bisected and fixed now: - One patch affects semtimedop() on many of the less common 32-bit architectures, this just needs a single-line bugfix. - The other affects only sparc64 and has a slightly more invasive workaround to apply the same change to sparc64 that was done to the generic code used everywhere else. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJddAhgAAoJEJpsee/mABjZCFsP/iV1iH6ezPC4thGazZ1n9wHw UOi+lVJPN3qZ2HmeSGYCFfktpbkj6UUT6QdwxfvZkD3EtKf1Zl+lMgJWAgE1/aUa ikCyKjSsnW3cv4Yd5uX9gYSzIdKrGY2XrDjq1J3hjUMPpZfj03ndKCYHEbMLDrO8 g91ZGUuHqxW0NCkDq6mGed2d0FOCLgwHqqwEEZgvaEzMDv1xG2TzrxS566YfxSVA HTD7JjsaEh02Q3AYwpq3MOxWXxDQE0b7YI+LoEs8Maqi+0zSh946vMVloo/a1pv2 SK9ol1zGQOwCojBTevcpHwdeeO2mYvjwDOa0aFucErAXiBPROXzFGIT/ZJ0WpZuf vI0JCCD3Rfp/oXRZePuToN2oE9HrrR6myhAMn+Nza3SbPlT/sQEaYvuStV/s8pQo HUNY234zACeRM5mPFUlbfYOBKL1loCpd+OjOA4fMoXGaG8HpnFBjnmz32yzo01zM oAiHzLXBeMLhJhZEX1b80rwbg4k/Kjn/ZQUEkQ0rc0+YEzXx/xd1FOsYtUgsDGFV hPvE7mO++1w9Wnu7dAIiCmk3qufF3oLjEngfHBcRy4gNxks7Ub9zEQwj9gCqbugq iHVQFQx25ToMnWHJ9ferkzj+eP1yFlkRiteoXMK0w5mU+3iF0qoTUbeMoucwlOmK VMncXfoiOdaOvQB6tQ/t =XsII -----END PGP SIGNATURE----- Merge tag 'ipc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic Pull ipc regression fixes from Arnd Bergmann: "Fix ipc regressions from y2038 patches These are two regression fixes for bugs that got introduced during the system call rework that went into linux-5.1 but only bisected and fixed now: - One patch affects semtimedop() on many of the less common 32-bit architectures, this just needs a single-line bugfix. - The other affects only sparc64 and has a slightly more invasive workaround to apply the same change to sparc64 that was done to the generic code used everywhere else" * tag 'ipc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic: ipc: fix sparc64 ipc() wrapper ipc: fix semtimedop for generic 32-bit architectures
This commit is contained in:
@ -336,25 +336,28 @@ SYSCALL_DEFINE6(sparc_ipc, unsigned int, call, int, first, unsigned long, second
|
||||
{
|
||||
long err;
|
||||
|
||||
if (!IS_ENABLED(CONFIG_SYSVIPC))
|
||||
return -ENOSYS;
|
||||
|
||||
/* No need for backward compatibility. We can start fresh... */
|
||||
if (call <= SEMTIMEDOP) {
|
||||
switch (call) {
|
||||
case SEMOP:
|
||||
err = sys_semtimedop(first, ptr,
|
||||
(unsigned int)second, NULL);
|
||||
err = ksys_semtimedop(first, ptr,
|
||||
(unsigned int)second, NULL);
|
||||
goto out;
|
||||
case SEMTIMEDOP:
|
||||
err = sys_semtimedop(first, ptr, (unsigned int)second,
|
||||
err = ksys_semtimedop(first, ptr, (unsigned int)second,
|
||||
(const struct __kernel_timespec __user *)
|
||||
(unsigned long) fifth);
|
||||
(unsigned long) fifth);
|
||||
goto out;
|
||||
case SEMGET:
|
||||
err = sys_semget(first, (int)second, (int)third);
|
||||
err = ksys_semget(first, (int)second, (int)third);
|
||||
goto out;
|
||||
case SEMCTL: {
|
||||
err = sys_semctl(first, second,
|
||||
(int)third | IPC_64,
|
||||
(unsigned long) ptr);
|
||||
err = ksys_old_semctl(first, second,
|
||||
(int)third | IPC_64,
|
||||
(unsigned long) ptr);
|
||||
goto out;
|
||||
}
|
||||
default:
|
||||
@ -365,18 +368,18 @@ SYSCALL_DEFINE6(sparc_ipc, unsigned int, call, int, first, unsigned long, second
|
||||
if (call <= MSGCTL) {
|
||||
switch (call) {
|
||||
case MSGSND:
|
||||
err = sys_msgsnd(first, ptr, (size_t)second,
|
||||
err = ksys_msgsnd(first, ptr, (size_t)second,
|
||||
(int)third);
|
||||
goto out;
|
||||
case MSGRCV:
|
||||
err = sys_msgrcv(first, ptr, (size_t)second, fifth,
|
||||
err = ksys_msgrcv(first, ptr, (size_t)second, fifth,
|
||||
(int)third);
|
||||
goto out;
|
||||
case MSGGET:
|
||||
err = sys_msgget((key_t)first, (int)second);
|
||||
err = ksys_msgget((key_t)first, (int)second);
|
||||
goto out;
|
||||
case MSGCTL:
|
||||
err = sys_msgctl(first, (int)second | IPC_64, ptr);
|
||||
err = ksys_old_msgctl(first, (int)second | IPC_64, ptr);
|
||||
goto out;
|
||||
default:
|
||||
err = -ENOSYS;
|
||||
@ -396,13 +399,13 @@ SYSCALL_DEFINE6(sparc_ipc, unsigned int, call, int, first, unsigned long, second
|
||||
goto out;
|
||||
}
|
||||
case SHMDT:
|
||||
err = sys_shmdt(ptr);
|
||||
err = ksys_shmdt(ptr);
|
||||
goto out;
|
||||
case SHMGET:
|
||||
err = sys_shmget(first, (size_t)second, (int)third);
|
||||
err = ksys_shmget(first, (size_t)second, (int)third);
|
||||
goto out;
|
||||
case SHMCTL:
|
||||
err = sys_shmctl(first, (int)second | IPC_64, ptr);
|
||||
err = ksys_old_shmctl(first, (int)second | IPC_64, ptr);
|
||||
goto out;
|
||||
default:
|
||||
err = -ENOSYS;
|
||||
|
@ -1402,4 +1402,23 @@ static inline unsigned int ksys_personality(unsigned int personality)
|
||||
return old;
|
||||
}
|
||||
|
||||
/* for __ARCH_WANT_SYS_IPC */
|
||||
long ksys_semtimedop(int semid, struct sembuf __user *tsops,
|
||||
unsigned int nsops,
|
||||
const struct __kernel_timespec __user *timeout);
|
||||
long ksys_semget(key_t key, int nsems, int semflg);
|
||||
long ksys_old_semctl(int semid, int semnum, int cmd, unsigned long arg);
|
||||
long ksys_msgget(key_t key, int msgflg);
|
||||
long ksys_old_msgctl(int msqid, int cmd, struct msqid_ds __user *buf);
|
||||
long ksys_msgrcv(int msqid, struct msgbuf __user *msgp, size_t msgsz,
|
||||
long msgtyp, int msgflg);
|
||||
long ksys_msgsnd(int msqid, struct msgbuf __user *msgp, size_t msgsz,
|
||||
int msgflg);
|
||||
long ksys_shmget(key_t key, size_t size, int shmflg);
|
||||
long ksys_shmdt(char __user *shmaddr);
|
||||
long ksys_old_shmctl(int shmid, int cmd, struct shmid_ds __user *buf);
|
||||
long compat_ksys_semtimedop(int semid, struct sembuf __user *tsems,
|
||||
unsigned int nsops,
|
||||
const struct old_timespec32 __user *timeout);
|
||||
|
||||
#endif
|
||||
|
@ -569,7 +569,7 @@ __SYSCALL(__NR_semget, sys_semget)
|
||||
__SC_COMP(__NR_semctl, sys_semctl, compat_sys_semctl)
|
||||
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
|
||||
#define __NR_semtimedop 192
|
||||
__SC_COMP(__NR_semtimedop, sys_semtimedop, sys_semtimedop_time32)
|
||||
__SC_3264(__NR_semtimedop, sys_semtimedop_time32, sys_semtimedop)
|
||||
#endif
|
||||
#define __NR_semop 193
|
||||
__SYSCALL(__NR_semop, sys_semop)
|
||||
|
25
ipc/util.h
25
ipc/util.h
@ -276,29 +276,7 @@ static inline int compat_ipc_parse_version(int *cmd)
|
||||
*cmd &= ~IPC_64;
|
||||
return version;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* for __ARCH_WANT_SYS_IPC */
|
||||
long ksys_semtimedop(int semid, struct sembuf __user *tsops,
|
||||
unsigned int nsops,
|
||||
const struct __kernel_timespec __user *timeout);
|
||||
long ksys_semget(key_t key, int nsems, int semflg);
|
||||
long ksys_old_semctl(int semid, int semnum, int cmd, unsigned long arg);
|
||||
long ksys_msgget(key_t key, int msgflg);
|
||||
long ksys_old_msgctl(int msqid, int cmd, struct msqid_ds __user *buf);
|
||||
long ksys_msgrcv(int msqid, struct msgbuf __user *msgp, size_t msgsz,
|
||||
long msgtyp, int msgflg);
|
||||
long ksys_msgsnd(int msqid, struct msgbuf __user *msgp, size_t msgsz,
|
||||
int msgflg);
|
||||
long ksys_shmget(key_t key, size_t size, int shmflg);
|
||||
long ksys_shmdt(char __user *shmaddr);
|
||||
long ksys_old_shmctl(int shmid, int cmd, struct shmid_ds __user *buf);
|
||||
|
||||
/* for CONFIG_ARCH_WANT_OLD_COMPAT_IPC */
|
||||
long compat_ksys_semtimedop(int semid, struct sembuf __user *tsems,
|
||||
unsigned int nsops,
|
||||
const struct old_timespec32 __user *timeout);
|
||||
#ifdef CONFIG_COMPAT
|
||||
long compat_ksys_old_semctl(int semid, int semnum, int cmd, int arg);
|
||||
long compat_ksys_old_msgctl(int msqid, int cmd, void __user *uptr);
|
||||
long compat_ksys_msgrcv(int msqid, compat_uptr_t msgp, compat_ssize_t msgsz,
|
||||
@ -306,6 +284,7 @@ long compat_ksys_msgrcv(int msqid, compat_uptr_t msgp, compat_ssize_t msgsz,
|
||||
long compat_ksys_msgsnd(int msqid, compat_uptr_t msgp,
|
||||
compat_ssize_t msgsz, int msgflg);
|
||||
long compat_ksys_old_shmctl(int shmid, int cmd, void __user *uptr);
|
||||
#endif /* CONFIG_COMPAT */
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user