Skip to contentSkip to conversation

mqueue: introduce new do_mq_timedreceive2() [ mq_peek syscall] for non-destructive receive and inspection,fix minor issue,prepared doc.

PATCH In review Mathura_Kumar 5 participants 6 messages Mar 6 – Mar 7

Subsystems (17)
lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 mqueue: introduce new do_mq_timedreceive2() [ mq_peek syscall] for non-destructive receive and inspection,fix minor issue,prepared doc.

Change from v3 to v5:

-Styles issue fixed
-Doc was prepared/modified in Documentation/userspace-api/ipc.rst, -Corrected file references
-I am squashing previous four commit in this latest one for convenience in applying
and merging
-risc-v related macro handling error fixed
-some struct definition removed from ipc/mqueue.c for better compiler control flow

Required Attention:-As per mail from bot

kernel test robot noticed the following build errors:
[auto build test ERROR on shuah-kselftest/next]
[also build test ERROR on shuah-kselftest/fixes next-20260304] [cannot apply to arnd-asm-generic/master linus/master tip/x86/asm v6.16-rc1]

Short Description:
POSIX message queues currently lack a mechanism to read a message without removing it from the queue. This is a long-standing limitation,when we require inspection of queue state without altering it.

Modifying existing mq_receive() semantics via additional flags was considered. However, altering behavior of an existing syscall risks breaking backward compatibility for applications relying on current semantics. Since mq_receive() guarantees message removal, changing this contract is not safe.

To preserve ABI stability, this patch introduces a new system call that performs a non-destructive receive operation (peek). The existing behavior remains unchanged.

Design considerations:

Two approaches for copying message data to userspace were evaluated:

1) Refcount-based message lifecycle handling
- This can help us Avoids intermediate temp kernel copy
- Extends message lifetime
-But this may increase writer starvation under heavy load and
add unnecessary complication on priority management and delay more time to free space in inode due refcount may prevent

2) Temporary kernel buffer copy
- Copies message into a bounded kernel buffer
- Reduces time message remains locked
- Improves fairness under write-heavy workloads
- Simpler lifetime management

My implementation adopts the temporary buffer approach to minimize starvation and reduce locking complexity. The design allows future transition if refcounting is deemed preferable.

Architecture support: ALL

Testing:
- 15+ functional test cases
- Multi-threaded producer/consumer scenarios
- concurrent pop and peek
- Edge cases: empty queue, FIFO invalid flags, signal interruption etc.

Use Case:

1) Observability in distributed systems
e.g Monitoring tools can inspect queue contents without interfering with
normal processing

2) Check pointing system can have a look into queue without consuming and can store messages

3) Resource-aware processing

4) Selective Consumption for Specialized Workers

---
 Documentation/userspace-api/index.rst       |   1 +
 Documentation/userspace-api/ipc.rst         | 273 +++++++
 arch/alpha/kernel/syscalls/syscall.tbl      |   1 +
 arch/arm/tools/syscall.tbl                  |   2 +
 arch/arm64/tools/syscall_32.tbl             |   2 +
 arch/m68k/kernel/syscalls/syscall.tbl       |   3 +
 arch/microblaze/kernel/syscalls/syscall.tbl |   3 +
 arch/mips/kernel/syscalls/syscall_n32.tbl   |   2 +
 arch/mips/kernel/syscalls/syscall_n64.tbl   |   1 +
 arch/mips/kernel/syscalls/syscall_o32.tbl   |   2 +
 arch/powerpc/kernel/syscalls/syscall.tbl    |   3 +
 arch/s390/kernel/syscalls/syscall.tbl       |   1 +
 arch/sh/kernel/syscalls/syscall.tbl         |   2 +
 arch/sparc/kernel/syscalls/syscall.tbl      |   3 +
 arch/x86/entry/syscalls/syscall_32.tbl      |   2 +
 arch/x86/entry/syscalls/syscall_64.tbl      |   2 +
 arch/xtensa/kernel/syscalls/syscall.tbl     |   2 +
 include/linux/syscalls.h                    |  10 +
 include/uapi/asm-generic/unistd.h           |  12 +-
 ipc/mqueue.c                                | 184 +++++
 ipc/msg.c                                   |   2 +-
 ipc/msgutil.c                               |  48 +-
 ipc/util.h                                  |   3 +-
 kernel/sys_ni.c                             |   2 +
 scripts/checksyscalls.sh                    |   1 +
 scripts/syscall.tbl                         |   3 +
 tools/testing/selftests/ipc/.gitignore      |   1 +
 tools/testing/selftests/ipc/Makefile        |   5 +-
 tools/testing/selftests/ipc/mq_peek.c       | 779 ++++++++++++++++++++
 29 files changed, 1323 insertions(+), 32 deletions(-)
 create mode 100644 Documentation/userspace-api/ipc.rst
 create mode 100644 tools/testing/selftests/ipc/mq_peek.c
Documentation/userspace-api/index.rst +1 -0
index a68b1bea57a8..bf747a91e74a 100644
@@ -22,6 +22,7 @@ System calls
    ioctl/index
    mseal
    rseq
+   ipc
 
 Security-related interfaces
 ===========================
Documentation/userspace-api/ipc.rst new file +273 -0

273 lines not on this page · raw message

arch/alpha/kernel/syscalls/syscall.tbl +1 -0
index f31b7afffc34..0ff42d241419 100644
@@ -511,3 +511,4 @@
 579	common	file_setattr			sys_file_setattr
 580	common	listns				sys_listns
 581	common	rseq_slice_yield		sys_rseq_slice_yield
+582	common	mq_timedreceive2		sys_mq_timedreceive2
arch/arm/tools/syscall.tbl +2 -0
index 94351e22bfcf..bcec28be852c 100644
@@ -486,3 +486,5 @@
 469	common	file_setattr			sys_file_setattr
 470	common	listns				sys_listns
 471	common	rseq_slice_yield		sys_rseq_slice_yield
+472	common	mq_timedreceive2		sys_mq_timedreceive2_time32
+473	common	mq_timedreceive2_time64	sys_mq_timedreceive2
arch/arm64/tools/syscall_32.tbl +2 -0
index 62d93d88e0fe..02603704231e 100644
@@ -483,3 +483,5 @@
 469	common	file_setattr			sys_file_setattr
 470	common	listns				sys_listns
 471	common	rseq_slice_yield		sys_rseq_slice_yield
+472	common	mq_timedreceive2_time64	sys_mq_timedreceive2
+473	common	mq_timedreceive2		sys_mq_timedreceive2_time32
arch/m68k/kernel/syscalls/syscall.tbl +3 -0
index 248934257101..b67f23edda11 100644
@@ -471,3 +471,6 @@
 469	common	file_setattr			sys_file_setattr
 470	common	listns				sys_listns
 471	common	rseq_slice_yield		sys_rseq_slice_yield
+472	common	mq_timedreceive2		sys_mq_timedreceive2_time32
+473	common	mq_timedreceive2_time64	sys_mq_timedreceive2
+
arch/microblaze/kernel/syscalls/syscall.tbl +3 -0
index 223d26303627..89fb60006a99 100644
@@ -477,3 +477,6 @@
 469	common	file_setattr			sys_file_setattr
 470	common	listns				sys_listns
 471	common	rseq_slice_yield		sys_rseq_slice_yield
+472	common	mq_timedreceive2		sys_mq_timedreceive2_time32
+473	common	mq_timedreceive2_time64	sys_mq_timedreceive2
+
arch/mips/kernel/syscalls/syscall_n32.tbl +2 -0
index 7430714e2b8f..fee830be67a6 100644
@@ -410,3 +410,5 @@
 469	n32	file_setattr			sys_file_setattr
 470	n32	listns				sys_listns
 471	n32	rseq_slice_yield		sys_rseq_slice_yield
+472	n32	mq_timedreceive2	    sys_mq_timedreceive2_time32
+473	n32	mq_timedreceive2_time64	sys_mq_timedreceive2
arch/mips/kernel/syscalls/syscall_n64.tbl +1 -0
index 630aab9e5425..75de6ee2df94 100644
@@ -386,3 +386,4 @@
 469	n64	file_setattr			sys_file_setattr
 470	n64	listns				sys_listns
 471	n64	rseq_slice_yield		sys_rseq_slice_yield
+472	n64	mq_timedreceive2		sys_mq_timedreceive2
arch/mips/kernel/syscalls/syscall_o32.tbl +2 -0
index 128653112284..8694a2d2f084 100644
@@ -459,3 +459,5 @@
 469	o32	file_setattr			sys_file_setattr
 470	o32	listns				sys_listns
 471	o32	rseq_slice_yield		sys_rseq_slice_yield
+472	o32	mq_timedreceive2	    sys_mq_timedreceive2_time32
+473	o32	mq_timedreceive2_time64	sys_mq_timedreceive2
arch/powerpc/kernel/syscalls/syscall.tbl +3 -0
index 4fcc7c58a105..fd90a2f500b6 100644
@@ -562,3 +562,6 @@
 469	common	file_setattr			sys_file_setattr
 470	common	listns				sys_listns
 471	nospu	rseq_slice_yield		sys_rseq_slice_yield
+472	32	mq_timedreceive2	        sys_mq_timedreceive2_time32
+473	64	mq_timedreceive2    		sys_mq_timedreceive2
+474	32	mq_timedreceive2_time64	    sys_mq_timedreceive2          sys_mq_timedreceive2
arch/s390/kernel/syscalls/syscall.tbl +1 -0
index 09a7ef04d979..34df682061d9 100644
@@ -398,3 +398,4 @@
 469	common	file_setattr			sys_file_setattr
 470	common	listns				sys_listns
 471	common	rseq_slice_yield		sys_rseq_slice_yield
+472	common	mq_timedreceive2		sys_mq_timedreceive2
arch/sh/kernel/syscalls/syscall.tbl +2 -0
index 70b315cbe710..1796ccd23d10 100644
@@ -475,3 +475,5 @@
 469	common	file_setattr			sys_file_setattr
 470	common	listns				sys_listns
 471	common	rseq_slice_yield		sys_rseq_slice_yield
+472	common	mq_timedreceive2		sys_mq_timedreceive2_time32
+473	common	mq_timedreceive2_time64		sys_mq_timedreceive2
arch/sparc/kernel/syscalls/syscall.tbl +3 -0
index 7e71bf7fcd14..5cfde6e0e6ba 100644
@@ -517,3 +517,6 @@
 469	common	file_setattr			sys_file_setattr
 470	common	listns				sys_listns
 471	common	rseq_slice_yield		sys_rseq_slice_yield
+472	32	mq_timedreceive2			sys_mq_timedreceive2_time32
+473	64	mq_timedreceive2			sys_mq_timedreceive2
+474	32	mq_timedreceive2_time64		sys_mq_timedreceive2		sys_mq_timedreceive2
arch/x86/entry/syscalls/syscall_32.tbl +2 -0
index f832ebd2d79b..d6701f763203 100644
@@ -477,3 +477,5 @@
 469	i386	file_setattr		sys_file_setattr
 470	i386	listns			sys_listns
 471	i386	rseq_slice_yield	sys_rseq_slice_yield
+472	i386	mq_timedreceive2	sys_mq_timedreceive2_time32
+473	i386	mq_timedreceive2_time64	sys_mq_timedreceive2
arch/x86/entry/syscalls/syscall_64.tbl +2 -0
index 524155d655da..539654953280 100644
@@ -441,3 +441,5 @@
 547	x32	pwritev2		compat_sys_pwritev64v2
 # This is the end of the legacy x32 range.  Numbers 548 and above are
 # not special and are not to be used for x32-specific syscalls.
+# Adding new syscalls from here to keep marginal gap intact in 472 to 511 for future expansion
+548	common	mq_timedreceive2		sys_mq_timedreceive2
arch/xtensa/kernel/syscalls/syscall.tbl +2 -0
index a9bca4e484de..9f69ef99e617 100644
@@ -442,3 +442,5 @@
 469	common	file_setattr			sys_file_setattr
 470	common	listns				sys_listns
 471	common	rseq_slice_yield		sys_rseq_slice_yield
+472	common	mq_timedreceive2		sys_mq_timedreceive2_time32
+473	common	mq_timedreceive2_time64		sys_mq_timedreceive2
include/linux/syscalls.h +10 -0
index 02bd6ddb6278..307cfd6f154c 100644
@@ -93,6 +93,7 @@ struct file_attr;
 #include <linux/key.h>
 #include <linux/personality.h>
 #include <trace/syscall.h>
+#include <linux/mqueue.h>
 
 #ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
 /*
@@ -746,6 +747,15 @@ asmlinkage long sys_mq_timedsend_time32(mqd_t mqdes,
 			const char __user *u_msg_ptr,
 			unsigned int msg_len, unsigned int msg_prio,
 			const struct old_timespec32 __user *u_abs_timeout);
+asmlinkage long
+sys_mq_timedreceive2(mqd_t mqdes, struct mq_timedreceive2_args __user *uargs,
+		     unsigned int flags, unsigned long index,
+		     struct __kernel_timespec __user *abs_timeout);
+asmlinkage long
+sys_mq_timedreceive2_time32(mqd_t mqdes,
+			    struct mq_timedreceive2_args __user *uargs,
+			    unsigned int flags, unsigned long index,
+			    struct old_timespec32 __user *abs_timeout);
 asmlinkage long sys_msgget(key_t key, int msgflg);
 asmlinkage long sys_old_msgctl(int msqid, int cmd, struct msqid_ds __user *buf);
 asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf);
include/uapi/asm-generic/unistd.h +10 -2
index a627acc8fb5f..3e1c580a8b1f 100644
@@ -863,9 +863,17 @@ __SYSCALL(__NR_listns, sys_listns)
 #define __NR_rseq_slice_yield 471
 __SYSCALL(__NR_rseq_slice_yield, sys_rseq_slice_yield)
 
-#undef __NR_syscalls
-#define __NR_syscalls 472
+#if defined(__SYSCALL_COMPAT) || __BITS_PER_LONG == 32
+#define __NR_mq_timedreceive2_time64 472
+__SYSCALL(__NR_mq_timedreceive2_time64, sys_mq_timedreceive2)
+#endif
+#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
+#define __NR_mq_timedreceive2 473
+__SC_3264(__NR_mq_timedreceive2, sys_mq_timedreceive2_time32, sys_mq_timedreceive2)
+#endif
 
+#undef __NR_syscalls
+#define __NR_syscalls 474
 /*
  * 32 bit systems traditionally used different
  * syscalls for off_t and loff_t arguments, while
ipc/mqueue.c +184 -0

226 lines not on this page · raw message

ipc/msg.c +1 -1
index 62996b97f0ac..6392b11dd7f7 100644
@@ -1156,7 +1156,7 @@ static long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp, in
 			 * not update queue parameters.
 			 */
 			if (msgflg & MSG_COPY) {
-				msg = copy_msg(msg, copy);
+				msg = copy_msg(msg, copy, msg->m_ts);
 				goto out_unlock0;
 			}
 
ipc/msgutil.c +21 -27

67 lines not on this page · raw message

ipc/util.h +2 -1
index a55d6cebe6d3..374abeee79b3 100644
@@ -197,8 +197,9 @@ int ipc_parse_version(int *cmd);
 
 extern void free_msg(struct msg_msg *msg);
 extern struct msg_msg *load_msg(const void __user *src, size_t len);
-extern struct msg_msg *copy_msg(struct msg_msg *src, struct msg_msg *dst);
+extern struct msg_msg *copy_msg(struct msg_msg *src, struct msg_msg *dst, size_t len);
 extern int store_msg(void __user *dest, struct msg_msg *msg, size_t len);
+extern struct msg_msg *alloc_msg(size_t len);
 
 static inline int ipc_checkid(struct kern_ipc_perm *ipcp, int id)
 {
kernel/sys_ni.c +2 -0
index add3032da16f..e6adc8c4220e 100644
@@ -391,6 +391,8 @@ COND_SYSCALL(setuid16);
 /* restartable sequence */
 COND_SYSCALL(rseq);
 COND_SYSCALL(rseq_slice_yield);
+COND_SYSCALL(mq_timedreceive2);
+COND_SYSCALL(mq_timedreceive2_time32);
 
 COND_SYSCALL(uretprobe);
 COND_SYSCALL(uprobe);
scripts/checksyscalls.sh +1 -0
index 1e5d2eeb726d..605a65cfa144 100755
@@ -104,6 +104,7 @@ cat << EOF
 #define __IGNORE_recvmmsg_time64
 #define __IGNORE_mq_timedsend_time64
 #define __IGNORE_mq_timedreceive_time64
+#define __IGNORE_mq_timedreceive2_time64
 #define __IGNORE_semtimedop_time64
 #define __IGNORE_rt_sigtimedwait_time64
 #define __IGNORE_futex_time64
scripts/syscall.tbl +3 -0
index 7a42b32b6577..57b711f93756 100644
@@ -412,3 +412,6 @@
 469	common	file_setattr			sys_file_setattr
 470	common	listns				sys_listns
 471	common	rseq_slice_yield		sys_rseq_slice_yield
+472  32      mq_timedreceive2_time64   sys_mq_timedreceive2
+473  64      mq_timedreceive2          sys_mq_timedreceive2
+473  time32  mq_timedreceive2          sys_mq_timedreceive2_time32
tools/testing/selftests/ipc/.gitignore +1 -0
index 9ed280e4c704..fe609d98ecb2 100644
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
 msgque_test
 msgque
+mq_peek
tools/testing/selftests/ipc/Makefile +4 -1
index 50e9c299fc4a..fa9d4f500783 100644
@@ -1,6 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
 uname_M := $(shell uname -m 2>/dev/null || echo not)
 ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/)
+CC = gcc
+CFLAGS = -static -O2
 ifeq ($(ARCH),i386)
         ARCH := x86
 	CFLAGS := -DCONFIG_X86_32 -D__i386__
@@ -12,7 +14,8 @@ endif
 
 CFLAGS += $(KHDR_INCLUDES)
 
-TEST_GEN_PROGS := msgque
+TEST_GEN_PROGS := msgque mq_peek
+LDLIBS += -lrt -lpthread
 
 include ../lib.mk
 
tools/testing/selftests/ipc/mq_peek.c new file +779 -0

779 lines not on this page · raw message

Signature · 1 line
2.43.0
#1 lore raw

Hi Mathura,

CC Arnd

Thanks for your patch!

Quoted 11 lines · Mathura_Kumar

Change from v3 to v5:

-Styles issue fixed
-Doc was prepared/modified in Documentation/userspace-api/ipc.rst, -Corrected file references
-I am squashing previous four commit in this latest one for convenience in applying
and merging
-risc-v related macro handling error fixed
-some struct definition removed from ipc/mqueue.c for better compiler control flow

Required Attention:-As per mail from bot

What does this mean?

Quoted 86 lines

kernel test robot noticed the following build errors:
[auto build test ERROR on shuah-kselftest/next]
[also build test ERROR on shuah-kselftest/fixes next-20260304] [cannot apply to arnd-asm-generic/master linus/master tip/x86/asm v6.16-rc1]

Short Description:
POSIX message queues currently lack a mechanism to read a message without removing it from the queue. This is a long-standing limitation,when we require inspection of queue state without altering it.

Modifying existing mq_receive() semantics via additional flags was considered. However, altering behavior of an existing syscall risks breaking backward compatibility for applications relying on current semantics. Since mq_receive() guarantees message removal, changing this contract is not safe.

To preserve ABI stability, this patch introduces a new system call that performs a non-destructive receive operation (peek). The existing behavior remains unchanged.

Design considerations:

Two approaches for copying message data to userspace were evaluated:

1) Refcount-based message lifecycle handling
- This can help us Avoids intermediate temp kernel copy
- Extends message lifetime
-But this may increase writer starvation under heavy load and
add unnecessary complication on priority management and delay more time to free space in inode due refcount may prevent

2) Temporary kernel buffer copy
- Copies message into a bounded kernel buffer
- Reduces time message remains locked
- Improves fairness under write-heavy workloads
- Simpler lifetime management

My implementation adopts the temporary buffer approach to minimize starvation and reduce locking complexity. The design allows future transition if refcounting is deemed preferable.

Architecture support: ALL

Testing:
- 15+ functional test cases
- Multi-threaded producer/consumer scenarios
- concurrent pop and peek
- Edge cases: empty queue, FIFO invalid flags, signal interruption etc.

Use Case:

1) Observability in distributed systems
e.g Monitoring tools can inspect queue contents without interfering with
normal processing

2) Check pointing system can have a look into queue without consuming and can store messages

3) Resource-aware processing

4) Selective Consumption for Specialized Workers

Documentation/userspace-api/index.rst +0 -0
Documentation/userspace-api/ipc.rst new file +10 -0
@@ -0,0 +1,273 @@
 
+1) Overview
+-----------
+
+POSIX message queues on Linux provide mq_receive() and mq_timedreceive()
+for consuming messages from a queue. Both interfaces require the caller
+to pass the message buffer, length, and priority pointer as individual
+arguments to the system call. This imposes a fixed calling convention
+that cannot be extended without breaking the ABI.
+
+mq_timedreceive2() introduces a new system call entry point that accepts

Documentation/userspace-api/ipc.rst line 37

Quoted 10 lines
Documentation/userspace-api/ipc.rst new file +10 -0
+message buffer parameters via a struct argument rather than as individual
+syscall arguments. This frees the remaining syscall argument slots for
+new functionality flags and a message index, enabling non-destructive
+peek and indexed access semantics that are not possible with the
+original interface.
+
+Two variants are provided:
+
+  mq_timedreceive2()         - primary variant, 64-bit time (Y2038-safe)
+  mq_timedreceive2_time32()  - 32-bit time variant for legacy and compat

What is the rationale behind adding a new syscall that is not Y2038-safe?

Quoted 45 lines
arch/arm/tools/syscall.tbl +2 -0
@@ -486,3 +486,5 @@
 469    common  file_setattr                    sys_file_setattr
 470    common  listns                          sys_listns
 471    common  rseq_slice_yield                sys_rseq_slice_yield
+472    common  mq_timedreceive2                sys_mq_timedreceive2_time32
+473    common  mq_timedreceive2_time64 sys_mq_timedreceive2
arch/arm64/tools/syscall_32.tbl +2 -0
index 62d93d88e0fe..02603704231e 100644
@@ -483,3 +483,5 @@
 469    common  file_setattr                    sys_file_setattr
 470    common  listns                          sys_listns
 471    common  rseq_slice_yield                sys_rseq_slice_yield
+472    common  mq_timedreceive2_time64 sys_mq_timedreceive2
+473    common  mq_timedreceive2                sys_mq_timedreceive2_time32
arch/m68k/kernel/syscalls/syscall.tbl +3 -0
index 248934257101..b67f23edda11 100644
@@ -471,3 +471,6 @@
 469    common  file_setattr                    sys_file_setattr
 470    common  listns                          sys_listns
 471    common  rseq_slice_yield                sys_rseq_slice_yield
+472    common  mq_timedreceive2                sys_mq_timedreceive2_time32
+473    common  mq_timedreceive2_time64 sys_mq_timedreceive2
+
arch/microblaze/kernel/syscalls/syscall.tbl +3 -0
index 223d26303627..89fb60006a99 100644
@@ -477,3 +477,6 @@
 469    common  file_setattr                    sys_file_setattr
 470    common  listns                          sys_listns
 471    common  rseq_slice_yield                sys_rseq_slice_yield
+472    common  mq_timedreceive2                sys_mq_timedreceive2_time32
+473    common  mq_timedreceive2_time64 sys_mq_timedreceive2
+
arch/mips/kernel/syscalls/syscall_n32.tbl +0 -0
index 7430714e2b8f..fee830be67a6 100644

arch/mips/kernel/syscalls/syscall_n32.tbl line 414

Quoted 5 lines
arch/mips/kernel/syscalls/syscall_n32.tbl +2 -0
@@ -410,3 +410,5 @@
 469    n32     file_setattr                    sys_file_setattr
 470    n32     listns                          sys_listns
 471    n32     rseq_slice_yield                sys_rseq_slice_yield
+472    n32     mq_timedreceive2            sys_mq_timedreceive2_time32
+473    n32     mq_timedreceive2_time64 sys_mq_timedreceive2

So these receive two variants...

arch/mips/kernel/syscalls/syscall_n64.tbl line 389

Quoted 9 lines
arch/mips/kernel/syscalls/syscall_n64.tbl +1 -0
index 630aab9e5425..75de6ee2df94 100644
@@ -386,3 +386,4 @@
 469    n64     file_setattr                    sys_file_setattr
 470    n64     listns                          sys_listns
 471    n64     rseq_slice_yield                sys_rseq_slice_yield
+472    n64     mq_timedreceive2                sys_mq_timedreceive2

MIPS64 receives only one?

Quoted 15 lines
arch/mips/kernel/syscalls/syscall_o32.tbl +2 -0
index 128653112284..8694a2d2f084 100644
@@ -459,3 +459,5 @@
 469    o32     file_setattr                    sys_file_setattr
 470    o32     listns                          sys_listns
 471    o32     rseq_slice_yield                sys_rseq_slice_yield
+472    o32     mq_timedreceive2            sys_mq_timedreceive2_time32
+473    o32     mq_timedreceive2_time64 sys_mq_timedreceive2
arch/powerpc/kernel/syscalls/syscall.tbl +0 -0
index 4fcc7c58a105..fd90a2f500b6 100644

arch/powerpc/kernel/syscalls/syscall.tbl line 567

Quoted 6 lines
arch/powerpc/kernel/syscalls/syscall.tbl +3 -0
@@ -562,3 +562,6 @@
 469    common  file_setattr                    sys_file_setattr
 470    common  listns                          sys_listns
 471    nospu   rseq_slice_yield                sys_rseq_slice_yield
+472    32      mq_timedreceive2                sys_mq_timedreceive2_time32
+473    64      mq_timedreceive2                sys_mq_timedreceive2
+474    32      mq_timedreceive2_time64     sys_mq_timedreceive2          sys_mq_timedreceive2

PowerPC receives three variants?
Oh, the first two are for 32-bit vs. 64-bit, so they should use the same syscall number.

More of this below...

Furthermore, this breaks the "new syscalls use the same number on most architectures"-rule. Next free slot is now 472, 473, or 474, depending on architecture.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer
#2 lore raw
Quoted 1 line · Geert Uytterhoeven

CC Arnd

Thanks!

Quoted 16 lines · Mathura_Kumar
Quoted 15 lines

+1) Overview
+-----------

Documentation/userspace-api/ipc.rst new file +12 -0
+
+POSIX message queues on Linux provide mq_receive() and mq_timedreceive()
+for consuming messages from a queue. Both interfaces require the caller
+to pass the message buffer, length, and priority pointer as individual
+arguments to the system call. This imposes a fixed calling convention
+that cannot be extended without breaking the ABI.
+
+mq_timedreceive2() introduces a new system call entry point that accepts
+message buffer parameters via a struct argument rather than as individual
+syscall arguments. This frees the remaining syscall argument slots for
+new functionality flags and a message index, enabling non-destructive
+peek and indexed access semantics that are not possible with the
Quoted 8 lines

Documentation/userspace-api/ipc.rst line 37

Quoted 6 lines
Documentation/userspace-api/ipc.rst new file +6 -0
+original interface.
+
+Two variants are provided:
+
+  mq_timedreceive2()         - primary variant, 64-bit time (Y2038-safe)
+  mq_timedreceive2_time32()  - 32-bit time variant for legacy and compat

What is the rationale behind adding a new syscall that is not Y2038-safe?

Indeed, that would need a very strong reason. New userspace already has to support old kernels without the syscalls, and it would seem easy enough to just not support it on time32 libc implementations.

Quoted 6 lines
Quoted 6 lines

index 4fcc7c58a105..fd90a2f500b6 100644

arch/powerpc/kernel/syscalls/syscall.tbl +0 -0
@@ -562,3 +562,6 @@
 469    common  file_setattr                    sys_file_setattr
 470    common  listns                          sys_listns
Quoted 8 lines

arch/powerpc/kernel/syscalls/syscall.tbl line 567

Quoted 4 lines
arch/powerpc/kernel/syscalls/syscall.tbl +3 -0
 471    nospu   rseq_slice_yield                sys_rseq_slice_yield
+472    32      mq_timedreceive2                sys_mq_timedreceive2_time32
+473    64      mq_timedreceive2                sys_mq_timedreceive2
+474    32      mq_timedreceive2_time64     sys_mq_timedreceive2          sys_mq_timedreceive2

PowerPC receives three variants?
Oh, the first two are for 32-bit vs. 64-bit, so they should use the same syscall number.

Probably just a typo there (same on sparc), I assume the intention was to use the same number as the generic scripts/syscall.tbl version.

Quoted 3 lines

Furthermore, this breaks the "new syscalls use the same number on most architectures"-rule. Next free slot is now 472, 473, or 474, depending on architecture.

Right. I also noticed a few more mistakes with the numbers:

- parisc is missing the syscall entirely
- arm32 compat mode has the numbers reversed compared to native mode
- x86 only gets a version in the 'x32' range, but is missing the native x86-64 version.
- The testcase hardcodes the x32 syscall number for all architectures other than a couple of hardcoded ones

Also, I would point out few more general issues:

- compat handling is is busted for the normal syscalls, and only seems to work by accident on the time32 one.
- the time32 syscall passes a kernel structure through a __user pointer
- this is the first patch (or public email) ever sent by the "author"
- the changelog text and subject line make no sense whatsoever
- four submissions of the series in three days, with the latest one labeled 'V5'.

I don't normally dismiss new submissions easily, but I think it's safe to ignore this one.

Arnd

reviewer
#3 lore raw
In reply to Mathura_Kumar

Warning: trailing whitespace in line 1763 of ipc/mqueue.c

Documentation/userspace-api/ipc.rst line 50

Quoted 12 lines · Mathura_Kumar

+2) Motivation
+-------------

Documentation/userspace-api/ipc.rst new file +10 -0
+
+The original mq_timedreceive() interface exhausts all usable syscall
+argument slots with mqdes, msg_ptr, msg_len, msg_prio, and abs_timeout.
+Adding new behavior such as peek-without-consume or indexed message
+access would require either a new syscall with a completely different
+signature, or overloading existing arguments in ways that harm clarity
+and correctness.
+
+By consolidating the message buffer parameters into a struct, this
+syscall recovers argument slots for:

End the line above with "for::" so that the following lines don't run together.

Documentation/userspace-api/ipc.rst line 57

Quoted 7 lines
Documentation/userspace-api/ipc.rst new file +7 -0
+
+  flags   - controls peek vs consume and other future behavior
+  index   - selects a specific message position in the priority queue
+
+This design follows the precedent of other Linux syscalls that use
+struct arguments to allow forward-compatible extensibility, such as
+clone3() and openat2().

How much AI use is present in this patch?

thanks.

Signature · 1 line
~Randy
#4 lore raw
In reply to Mathura_Kumar
kernel test robot noticed the following build errors:

Hi Mathura_Kumar,

kernel test robot noticed the following build errors:

[auto build test ERROR on shuah-kselftest/next]
[also build test ERROR on shuah-kselftest/fixes brauner-vfs/vfs.all linus/master v7.0-rc2 next-20260306] [cannot apply to tip/x86/asm]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mathura_Kumar/mqueue-introduce-new-do_mq_timedreceive2-mq_peek-syscall-for-non-destructive-receive-and-inspection-fix-minor-issue-prep/20260306-155240
base:   https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git next
patch link:    https://lore.kernel.org/r/20260306075009.83723-1-academic1mathura%40gmail.com
patch subject: [PATCH] [PATCH V5] mqueue: introduce new do_mq_timedreceive2() [ mq_peek syscall] for non-destructive receive and inspection,fix minor issue,prepared doc.
config: powerpc-randconfig-r053-20260307 (https://download.01.org/0day-ci/archive/20260307/[email protected]/config)
compiler: powerpc-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260307/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

include/linux/syscalls.h:122:27: note: in expansion of macro '__SC_LONG'

    #define __MAP4(m,t,a,...) m(t,a), __MAP3(m,__VA_ARGS__)
                              ^
   include/linux/syscalls.h:123:35: note: in expansion of macro '__MAP4'
    #define __MAP5(m,t,a,...) m(t,a), __MAP4(m,__VA_ARGS__)
                                      ^~~~~~
   include/linux/syscalls.h:125:22: note: in expansion of macro '__MAP5'
    #define __MAP(n,...) __MAP##n(__VA_ARGS__)
                         ^~~~~
   arch/powerpc/include/asm/syscall_wrapper.h:27:29: note: in expansion of macro '__MAP'
     static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__))  \
                                ^~~~~
   include/linux/syscalls.h:237:2: note: in expansion of macro '__SYSCALL_DEFINEx'
     __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
     ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:230:36: note: in expansion of macro 'SYSCALL_DEFINEx'
    #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
                                       ^~~~~~~~~~~~~~~
   ipc/mqueue.c:1747:1: note: in expansion of macro 'SYSCALL_DEFINE5'
    SYSCALL_DEFINE5(mq_timedreceive2_time32, mqd_t, mqdes,
    ^~~~~~~~~~~~~~~
   In file included from ipc/mqueue.c:29:
   ipc/mqueue.c: In function '__se_sys_mq_timedreceive2_time32':
   include/linux/syscalls.h:133:25: error: passing argument 2 of '__do_sys_mq_timedreceive2_time32' from incompatible pointer type [-Werror=incompatible-pointer-types]
    #define __SC_CAST(t, a) (__force t) a
   include/linux/syscalls.h:122:27: note: in expansion of macro '__SC_CAST'
    #define __MAP4(m,t,a,...) m(t,a), __MAP3(m,__VA_ARGS__)
                              ^
   include/linux/syscalls.h:123:35: note: in expansion of macro '__MAP4'
    #define __MAP5(m,t,a,...) m(t,a), __MAP4(m,__VA_ARGS__)
                                      ^~~~~~
   include/linux/syscalls.h:125:22: note: in expansion of macro '__MAP5'
    #define __MAP(n,...) __MAP##n(__VA_ARGS__)
                         ^~~~~
   arch/powerpc/include/asm/syscall_wrapper.h:29:29: note: in expansion of macro '__MAP'
      long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \
                                ^~~~~
   include/linux/syscalls.h:237:2: note: in expansion of macro '__SYSCALL_DEFINEx'
     __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
     ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:230:36: note: in expansion of macro 'SYSCALL_DEFINEx'
    #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
                                       ^~~~~~~~~~~~~~~
   ipc/mqueue.c:1747:1: note: in expansion of macro 'SYSCALL_DEFINE5'
    SYSCALL_DEFINE5(mq_timedreceive2_time32, mqd_t, mqdes,
    ^~~~~~~~~~~~~~~
   ipc/mqueue.c:1748:49: note: expected 'struct compat_mq_timedreceive2_args *' but argument is of type 'struct compat_mq_timedreceive2_args *'
      struct compat_mq_timedreceive2_args __user *, uargs,
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
   include/linux/syscalls.h:127:27: note: in definition of macro '__SC_DECL'
    #define __SC_DECL(t, a) t a
                              ^
   include/linux/syscalls.h:123:35: note: in expansion of macro '__MAP4'
    #define __MAP5(m,t,a,...) m(t,a), __MAP4(m,__VA_ARGS__)
                                      ^~~~~~
   include/linux/syscalls.h:125:22: note: in expansion of macro '__MAP5'
    #define __MAP(n,...) __MAP##n(__VA_ARGS__)
                         ^~~~~
   arch/powerpc/include/asm/syscall_wrapper.h:22:36: note: in expansion of macro '__MAP'
     static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
                                       ^~~~~
   include/linux/syscalls.h:237:2: note: in expansion of macro '__SYSCALL_DEFINEx'
     __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
     ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:230:36: note: in expansion of macro 'SYSCALL_DEFINEx'
    #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
                                       ^~~~~~~~~~~~~~~
   ipc/mqueue.c:1747:1: note: in expansion of macro 'SYSCALL_DEFINE5'
    SYSCALL_DEFINE5(mq_timedreceive2_time32, mqd_t, mqdes,
    ^~~~~~~~~~~~~~~
   ipc/mqueue.c: At top level:
   ipc/mqueue.c:1748:10: warning: 'struct compat_mq_timedreceive2_args' declared inside parameter list will not be visible outside of this definition or declaration
      struct compat_mq_timedreceive2_args __user *, uargs,
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:127:25: note: in definition of macro '__SC_DECL'
    #define __SC_DECL(t, a) t a
                            ^
   include/linux/syscalls.h:123:35: note: in expansion of macro '__MAP4'
    #define __MAP5(m,t,a,...) m(t,a), __MAP4(m,__VA_ARGS__)
                                      ^~~~~~
   include/linux/syscalls.h:125:22: note: in expansion of macro '__MAP5'
    #define __MAP(n,...) __MAP##n(__VA_ARGS__)
                         ^~~~~
   arch/powerpc/include/asm/syscall_wrapper.h:34:36: note: in expansion of macro '__MAP'
     static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
                                       ^~~~~
   include/linux/syscalls.h:237:2: note: in expansion of macro '__SYSCALL_DEFINEx'
     __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
     ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:230:36: note: in expansion of macro 'SYSCALL_DEFINEx'
    #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
                                       ^~~~~~~~~~~~~~~
   ipc/mqueue.c:1747:1: note: in expansion of macro 'SYSCALL_DEFINE5'
    SYSCALL_DEFINE5(mq_timedreceive2_time32, mqd_t, mqdes,
    ^~~~~~~~~~~~~~~
   In file included from include/linux/compat.h:34,
                    from include/net/compat.h:8,
                    from include/net/scm.h:13,
                    from include/linux/netlink.h:9,
                    from ipc/mqueue.c:28:
>> arch/powerpc/include/asm/syscall_wrapper.h:34:21: error: conflicting types for '__do_sys_mq_timedreceive2_time32'
     static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
                        ^~~~~~~~
   include/linux/syscalls.h:237:2: note: in expansion of macro '__SYSCALL_DEFINEx'
     __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
     ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:230:36: note: in expansion of macro 'SYSCALL_DEFINEx'
    #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
                                       ^~~~~~~~~~~~~~~
   ipc/mqueue.c:1747:1: note: in expansion of macro 'SYSCALL_DEFINE5'
    SYSCALL_DEFINE5(mq_timedreceive2_time32, mqd_t, mqdes,
    ^~~~~~~~~~~~~~~
   arch/powerpc/include/asm/syscall_wrapper.h:22:21: note: previous declaration of '__do_sys_mq_timedreceive2_time32' was here
     static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
                        ^~~~~~~~
   include/linux/syscalls.h:237:2: note: in expansion of macro '__SYSCALL_DEFINEx'
     __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
     ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:230:36: note: in expansion of macro 'SYSCALL_DEFINEx'
    #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
                                       ^~~~~~~~~~~~~~~
   ipc/mqueue.c:1747:1: note: in expansion of macro 'SYSCALL_DEFINE5'
    SYSCALL_DEFINE5(mq_timedreceive2_time32, mqd_t, mqdes,
    ^~~~~~~~~~~~~~~
   ipc/mqueue.c: In function '__do_sys_mq_timedreceive2_time32':
   ipc/mqueue.c:1756:6: error: implicit declaration of function 'get_compat_mq_args'; did you mean 'get_compat_msghdr'? [-Werror=implicit-function-declaration]
     if (get_compat_mq_args(pargs, uargs))
         ^~~~~~~~~~~~~~~~~~
         get_compat_msghdr
   In file included from include/linux/compat.h:34,
                    from include/net/compat.h:8,
                    from include/net/scm.h:13,
                    from include/linux/netlink.h:9,
                    from ipc/mqueue.c:28:
   ipc/mqueue.c: At top level:
   arch/powerpc/include/asm/syscall_wrapper.h:22:21: warning: '__do_sys_mq_timedreceive2_time32' used but never defined
     static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
                        ^~~~~~~~
   include/linux/syscalls.h:237:2: note: in expansion of macro '__SYSCALL_DEFINEx'
     __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
     ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:230:36: note: in expansion of macro 'SYSCALL_DEFINEx'
    #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
                                       ^~~~~~~~~~~~~~~

ipc/mqueue.c:1747:1: note: in expansion of macro 'SYSCALL_DEFINE5'
SYSCALL_DEFINE5(mq_timedreceive2_time32, mqd_t, mqdes, ^~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

vim +/__do_sys_mq_timedreceive2_time32 +34 arch/powerpc/include/asm/syscall_wrapper.h

7e92e01b724526 Rohan McLure     2022-09-21  12  
7e92e01b724526 Rohan McLure     2022-09-21  13  #define SC_POWERPC_REGS_TO_ARGS(x, ...)				\
7e92e01b724526 Rohan McLure     2022-09-21  14  	__MAP(x,__SC_ARGS					\
7e92e01b724526 Rohan McLure     2022-09-21  15  	      ,,regs->gpr[3],,regs->gpr[4],,regs->gpr[5]	\
7e92e01b724526 Rohan McLure     2022-09-21  16  	      ,,regs->gpr[6],,regs->gpr[7],,regs->gpr[8])
7e92e01b724526 Rohan McLure     2022-09-21  17  
7e92e01b724526 Rohan McLure     2022-09-21  18  #define __SYSCALL_DEFINEx(x, name, ...)						\
94746890202cf1 Michael Ellerman 2022-10-06  19  	long sys##name(const struct pt_regs *regs);			\
94746890202cf1 Michael Ellerman 2022-10-06  20  	ALLOW_ERROR_INJECTION(sys##name, ERRNO);			\
7e92e01b724526 Rohan McLure     2022-09-21  21  	static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__));		\
7e92e01b724526 Rohan McLure     2022-09-21  22  	static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));	\
94746890202cf1 Michael Ellerman 2022-10-06  23  	long sys##name(const struct pt_regs *regs)			\
7e92e01b724526 Rohan McLure     2022-09-21  24  	{									\
7e92e01b724526 Rohan McLure     2022-09-21  25  		return __se_sys##name(SC_POWERPC_REGS_TO_ARGS(x,__VA_ARGS__));	\
7e92e01b724526 Rohan McLure     2022-09-21  26  	}									\
7e92e01b724526 Rohan McLure     2022-09-21  27  	static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__))		\
7e92e01b724526 Rohan McLure     2022-09-21  28  	{									\
7e92e01b724526 Rohan McLure     2022-09-21  29  		long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__));	\
7e92e01b724526 Rohan McLure     2022-09-21  30  		__MAP(x,__SC_TEST,__VA_ARGS__);					\
7e92e01b724526 Rohan McLure     2022-09-21  31  		__PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__));		\
7e92e01b724526 Rohan McLure     2022-09-21  32  		return ret;							\
7e92e01b724526 Rohan McLure     2022-09-21  33  	}									\

7e92e01b724526 Rohan McLure 2022-09-21 @34 static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
7e92e01b724526 Rohan McLure 2022-09-21 35

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#5 lore raw
In reply to Mathura_Kumar
kernel test robot noticed the following build errors:

Hi Mathura_Kumar,

kernel test robot noticed the following build errors:

[auto build test ERROR on shuah-kselftest/next]
[also build test ERROR on shuah-kselftest/fixes brauner-vfs/vfs.all linus/master v7.0-rc2 next-20260306] [cannot apply to tip/x86/asm]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mathura_Kumar/mqueue-introduce-new-do_mq_timedreceive2-mq_peek-syscall-for-non-destructive-receive-and-inspection-fix-minor-issue-prep/20260306-155240
base:   https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git next
patch link:    https://lore.kernel.org/r/20260306075009.83723-1-academic1mathura%40gmail.com
patch subject: [PATCH] [PATCH V5] mqueue: introduce new do_mq_timedreceive2() [ mq_peek syscall] for non-destructive receive and inspection,fix minor issue,prepared doc.
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20260307/[email protected]/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260307/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

ipc/mqueue.c:1748:10: warning: declaration of 'struct compat_mq_timedreceive2_args' will not be visible outside of this function [-Wvisibility]
1748 | struct compat_mq_timedreceive2_args __user *, uargs,
| ^
ipc/mqueue.c:1748:10: warning: declaration of 'struct compat_mq_timedreceive2_args' will not be visible outside of this function [-Wvisibility] ipc/mqueue.c:1748:10: warning: declaration of 'struct compat_mq_timedreceive2_args' will not be visible outside of this function [-Wvisibility]

>> ipc/mqueue.c:1747:1: error: incompatible pointer types passing 'struct compat_mq_timedreceive2_args *' to parameter of type 'struct compat_mq_timedreceive2_args *' [-Werror,-Wincompatible-pointer-types]
    1747 | SYSCALL_DEFINE5(mq_timedreceive2_time32, mqd_t, mqdes,
         | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1748 |                 struct compat_mq_timedreceive2_args __user *, uargs,
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1749 |                 unsigned int, flags, const unsigned long, index,
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1750 |                 const struct old_timespec32 __user *, u_abs_timeout)
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:230:36: note: expanded from macro 'SYSCALL_DEFINE5'
     230 | #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
         |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:237:2: note: expanded from macro 'SYSCALL_DEFINEx'
     237 |         __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/x86/include/asm/syscall_wrapper.h:230:37: note: expanded from macro '__SYSCALL_DEFINEx'
     230 |                 long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__));\
         |                                           ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/syscalls.h:123:42: note: expanded from macro '__MAP5'
     123 | #define __MAP5(m,t,a,...) m(t,a), __MAP4(m,__VA_ARGS__)
         |                                   ~~~~~~~^~~~~~~~~~~~~~
   include/linux/syscalls.h:122:27: note: expanded from macro '__MAP4'
     122 | #define __MAP4(m,t,a,...) m(t,a), __MAP3(m,__VA_ARGS__)
         |                           ^~~~~~
   include/linux/syscalls.h:133:25: note: expanded from macro '__SC_CAST'
     133 | #define __SC_CAST(t, a) (__force t) a
         |                         ^~~~~~~~~~~~~
   ipc/mqueue.c:1748:49: note: passing argument to parameter 'uargs' here
    1748 |                 struct compat_mq_timedreceive2_args __user *, uargs,
         |                                                               ^
   ipc/mqueue.c:1748:10: warning: declaration of 'struct compat_mq_timedreceive2_args' will not be visible outside of this function [-Wvisibility]
    1748 |                 struct compat_mq_timedreceive2_args __user *, uargs,
         |                        ^
>> ipc/mqueue.c:1747:1: error: conflicting types for '__do_sys_mq_timedreceive2_time32'
    1747 | SYSCALL_DEFINE5(mq_timedreceive2_time32, mqd_t, mqdes,
         | ^
   include/linux/syscalls.h:230:36: note: expanded from macro 'SYSCALL_DEFINE5'
     230 | #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
         |                                    ^
   include/linux/syscalls.h:237:2: note: expanded from macro 'SYSCALL_DEFINEx'
     237 |         __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
         |         ^
   arch/x86/include/asm/syscall_wrapper.h:235:21: note: expanded from macro '__SYSCALL_DEFINEx'
     235 |         static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
         |                            ^
   <scratch space>:71:1: note: expanded from here
      71 | __do_sys_mq_timedreceive2_time32
         | ^
   ipc/mqueue.c:1747:1: note: previous declaration is here
   include/linux/syscalls.h:230:36: note: expanded from macro 'SYSCALL_DEFINE5'
     230 | #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
         |                                    ^
   include/linux/syscalls.h:237:2: note: expanded from macro 'SYSCALL_DEFINEx'
     237 |         __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
         |         ^
   arch/x86/include/asm/syscall_wrapper.h:225:21: note: expanded from macro '__SYSCALL_DEFINEx'
     225 |         static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
         |                            ^
   <scratch space>:44:1: note: expanded from here
      44 | __do_sys_mq_timedreceive2_time32
         | ^
>> ipc/mqueue.c:1756:6: error: call to undeclared function 'get_compat_mq_args'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

1756 | if (get_compat_mq_args(pargs, uargs))
| ^
ipc/mqueue.c:1756:6: note: did you mean 'get_compat_msghdr'? include/net/compat.h:51:5: note: 'get_compat_msghdr' declared here
51 | int get_compat_msghdr(struct msghdr *, struct compat_msghdr __user *,
| ^
4 warnings and 3 errors generated.

vim +1747 ipc/mqueue.c

1746

> 1747	SYSCALL_DEFINE5(mq_timedreceive2_time32, mqd_t, mqdes,
> 1748			struct compat_mq_timedreceive2_args __user *, uargs,
  1749			unsigned int, flags, const unsigned long, index,
  1750			const struct old_timespec32 __user *, u_abs_timeout)
  1751	{
  1752		struct mq_timedreceive2_args args, *pargs = NULL;
  1753	
  1754		pargs = &args;
  1755	
> 1756		if (get_compat_mq_args(pargs, uargs))

1757 return -EFAULT;
1758
1759 struct timespec64 ts, *p = NULL;
1760
1761 if (u_abs_timeout) {
1762 int res = compat_prepare_timeout(u_abs_timeout, &ts);
1763
1764 if (res)
1765 return res;
1766 p = &ts;
1767 }
1768 return do_mq_timedreceive2(mqdes, pargs, flags, index, p);
1769 }
1770 #endif
1771

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki