[PATCH 1/2] uapi: Stop using __kernel_long_t in struct msgbuf

From: Harald van Dijk
Date: Sun Sep 10 2023 - 19:43:23 EST


struct msgbuf is mostly an internal type: msgsnd and msgrcv have always
been documented as taking a pointer to a user-defined type starting with
a field of type long. __kernel_long_t is the same as long for all
platforms other than x32, almost all code out there using msgsnd and
msgrcv uses them as documented, and it is impossible to simultaneously
support existing binaries that use the documented API and existing
binaries that use the implemented API. This change breaks existing x32
binaries that use the implemented API, and fixes existing x32 binaries
that use the documented API.

This reverts commit 443d5670f77aab121cb95f45da60f0aad390bcb5.

Signed-off-by: Harald van Dijk <harald@xxxxxxxxxxx>
Cc: stable@xxxxxxxxxx
---
arch/x86/entry/syscalls/syscall_64.tbl | 6 ++++--
include/uapi/linux/msg.h | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl
index 1d6eee30eceb2..f5d81fe2c94ca 100644
--- a/arch/x86/entry/syscalls/syscall_64.tbl
+++ b/arch/x86/entry/syscalls/syscall_64.tbl
@@ -77,8 +77,10 @@
66 common semctl sys_semctl
67 common shmdt sys_shmdt
68 common msgget sys_msgget
-69 common msgsnd sys_msgsnd
-70 common msgrcv sys_msgrcv
+69 64 msgsnd sys_msgsnd
+69 x32 msgsnd compat_sys_msgsnd
+70 64 msgrcv sys_msgrcv
+70 x32 msgrcv compat_sys_msgrcv
71 common msgctl sys_msgctl
72 common fcntl sys_fcntl
73 common flock sys_flock
diff --git a/include/uapi/linux/msg.h b/include/uapi/linux/msg.h
index 01ee8d54c1c8a..3881c94d48eae 100644
--- a/include/uapi/linux/msg.h
+++ b/include/uapi/linux/msg.h
@@ -36,7 +36,7 @@ struct msqid_ds {
/* message buffer for msgsnd and msgrcv calls */
struct msgbuf {
- __kernel_long_t mtype; /* type of message */
+ long mtype; /* type of message */
char mtext[1]; /* message text */
};
--
2.34.1