Skip to content

Commit b0d1757

Browse files
committed
y2038: ipc: Enable COMPAT_32BIT_TIME
Three ipc syscalls (mq_timedsend, mq_timedreceive and and semtimedop) take a timespec argument. After we move 32-bit architectures over to useing 64-bit time_t based syscalls, we need seperate entry points for the old 32-bit based interfaces. This changes the #ifdef guards for the existing 32-bit compat syscalls to check for CONFIG_COMPAT_32BIT_TIME instead, which will then be enabled on all existing 32-bit architectures. Signed-off-by: Arnd Bergmann <[email protected]>
1 parent 21fc538 commit b0d1757

File tree

3 files changed

+44
-41
lines changed

3 files changed

+44
-41
lines changed

ipc/mqueue.c

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,47 @@ COMPAT_SYSCALL_DEFINE4(mq_open, const char __user *, u_name,
14201420
return do_mq_open(u_name, oflag, mode, p);
14211421
}
14221422

1423+
COMPAT_SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes,
1424+
const struct compat_sigevent __user *, u_notification)
1425+
{
1426+
struct sigevent n, *p = NULL;
1427+
if (u_notification) {
1428+
if (get_compat_sigevent(&n, u_notification))
1429+
return -EFAULT;
1430+
if (n.sigev_notify == SIGEV_THREAD)
1431+
n.sigev_value.sival_ptr = compat_ptr(n.sigev_value.sival_int);
1432+
p = &n;
1433+
}
1434+
return do_mq_notify(mqdes, p);
1435+
}
1436+
1437+
COMPAT_SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes,
1438+
const struct compat_mq_attr __user *, u_mqstat,
1439+
struct compat_mq_attr __user *, u_omqstat)
1440+
{
1441+
int ret;
1442+
struct mq_attr mqstat, omqstat;
1443+
struct mq_attr *new = NULL, *old = NULL;
1444+
1445+
if (u_mqstat) {
1446+
new = &mqstat;
1447+
if (get_compat_mq_attr(new, u_mqstat))
1448+
return -EFAULT;
1449+
}
1450+
if (u_omqstat)
1451+
old = &omqstat;
1452+
1453+
ret = do_mq_getsetattr(mqdes, new, old);
1454+
if (ret || !old)
1455+
return ret;
1456+
1457+
if (put_compat_mq_attr(old, u_omqstat))
1458+
return -EFAULT;
1459+
return 0;
1460+
}
1461+
#endif
1462+
1463+
#ifdef CONFIG_COMPAT_32BIT_TIME
14231464
static int compat_prepare_timeout(const struct compat_timespec __user *p,
14241465
struct timespec64 *ts)
14251466
{
@@ -1459,45 +1500,6 @@ COMPAT_SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes,
14591500
}
14601501
return do_mq_timedreceive(mqdes, u_msg_ptr, msg_len, u_msg_prio, p);
14611502
}
1462-
1463-
COMPAT_SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes,
1464-
const struct compat_sigevent __user *, u_notification)
1465-
{
1466-
struct sigevent n, *p = NULL;
1467-
if (u_notification) {
1468-
if (get_compat_sigevent(&n, u_notification))
1469-
return -EFAULT;
1470-
if (n.sigev_notify == SIGEV_THREAD)
1471-
n.sigev_value.sival_ptr = compat_ptr(n.sigev_value.sival_int);
1472-
p = &n;
1473-
}
1474-
return do_mq_notify(mqdes, p);
1475-
}
1476-
1477-
COMPAT_SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes,
1478-
const struct compat_mq_attr __user *, u_mqstat,
1479-
struct compat_mq_attr __user *, u_omqstat)
1480-
{
1481-
int ret;
1482-
struct mq_attr mqstat, omqstat;
1483-
struct mq_attr *new = NULL, *old = NULL;
1484-
1485-
if (u_mqstat) {
1486-
new = &mqstat;
1487-
if (get_compat_mq_attr(new, u_mqstat))
1488-
return -EFAULT;
1489-
}
1490-
if (u_omqstat)
1491-
old = &omqstat;
1492-
1493-
ret = do_mq_getsetattr(mqdes, new, old);
1494-
if (ret || !old)
1495-
return ret;
1496-
1497-
if (put_compat_mq_attr(old, u_omqstat))
1498-
return -EFAULT;
1499-
return 0;
1500-
}
15011503
#endif
15021504

15031505
static const struct inode_operations mqueue_dir_inode_operations = {

ipc/sem.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
* The worst-case behavior is nevertheless O(N^2) for N wakeups.
7171
*/
7272

73+
#include <linux/compat.h>
7374
#include <linux/slab.h>
7475
#include <linux/spinlock.h>
7576
#include <linux/init.h>
@@ -2193,7 +2194,7 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
21932194
return ksys_semtimedop(semid, tsops, nsops, timeout);
21942195
}
21952196

2196-
#ifdef CONFIG_COMPAT
2197+
#ifdef CONFIG_COMPAT_32BIT_TIME
21972198
long compat_ksys_semtimedop(int semid, struct sembuf __user *tsems,
21982199
unsigned int nsops,
21992200
const struct compat_timespec __user *timeout)

ipc/util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,10 @@ long ksys_shmdt(char __user *shmaddr);
265265
long ksys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf);
266266

267267
/* for CONFIG_ARCH_WANT_OLD_COMPAT_IPC */
268-
#ifdef CONFIG_COMPAT
269268
long compat_ksys_semtimedop(int semid, struct sembuf __user *tsems,
270269
unsigned int nsops,
271270
const struct compat_timespec __user *timeout);
271+
#ifdef CONFIG_COMPAT
272272
long compat_ksys_semctl(int semid, int semnum, int cmd, int arg);
273273
long compat_ksys_msgctl(int msqid, int cmd, void __user *uptr);
274274
long compat_ksys_msgrcv(int msqid, compat_uptr_t msgp, compat_ssize_t msgsz,

0 commit comments

Comments
 (0)