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 3 participants 3 messages Mar 5 – Mar 6

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

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

First of all Thanks for constructive response,I am new to kernel development so in earlier patch has some style issue

what changed now:-

1)As per my estimate all style issue fixed
2)Doc was prepared in Documentation/userspace-api/syscall.rst, for better
consistency, i was not making inline comment for doc in source code
3)I am squashing previous three commit in this latest one for convenience in applying
and merging

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]

As per my guess bot failed to apply all earlier patch in order,now As Squashed, it should not come but if it then required manual intervention, I tested Successfully on x86-64 bit host arch for x86-64,arm64,risc-v and all test.

some note:-macro and header guard are extermally sensetive for order of sys call number on risc-v ,after of hour testing ,hit and trail and i fix that

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 unneassery 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.

---
 Documentation/userspace-api/index.rst       |   1 +
 Documentation/userspace-api/syscall.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                                | 183 +++++
 ipc/msg.c                                   |   2 +-
 ipc/msgutil.c                               |  49 +-
 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       | 794 ++++++++++++++++++++
 29 files changed, 1337 insertions(+), 33 deletions(-)
 create mode 100644 Documentation/userspace-api/syscall.rst
 create mode 100644 tools/testing/selftests/ipc/mq_peek.c
Documentation/userspace-api/index.rst +1 -0
index a68b1bea57a8..119f820a5a1d 100644
@@ -22,6 +22,7 @@ System calls
    ioctl/index
    mseal
    rseq
+   syscall
 
 Security-related interfaces
 ===========================
Documentation/userspace-api/syscall.rst new file +273 -0

274 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 +183 -0

225 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 -28

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 +794 -0

794 lines not on this page · raw message

Signature · 1 line
2.43.0
reviewer
#1 lore raw

Hi,

Quoted 3 lines · Mathura_Kumar

First of all Thanks for constructive response,I am new to kernel development so in earlier patch has some style issue

That ^^^ should be in a cover letter or below the "---" line, The Subject: should say [PATCH v2].
This (following) list of changes from v1 to v2 should also be below the "---" line and not part of the patch description. For v3, leave the v1->v2 changes and add v2->v3 changes, etc.

Quoted 16 lines

what changed now:-

1)As per my estimate all style issue fixed
2)Doc was prepared in Documentation/userspace-api/syscall.rst, for better
consistency, i was not making inline comment for doc in source code
3)I am squashing previous three commit in this latest one for convenience in applying
and merging

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]

Quoted 5 lines

As per my guess bot failed to apply all earlier patch in order,now As Squashed, it should not come but if it then required manual intervention, I tested Successfully on x86-64 bit host arch for x86-64,arm64,risc-v and all test.

some note:-macro and header guard are extermally sensetive for order of sys call number

extremely sensitive

Quoted 22 lines

on risc-v ,after of hour testing ,hit and trail and i fix that

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:

Quoted 8 lines

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 unneassery complication on priority management and

unnecessary

Quoted 13 lines

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.

Quoted 8 lines

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.

Is there a use case or user for this syscall?
If so, please describe it (or them) here.

Quoted 10 lines

---

Documentation/userspace-api/index.rst +0 -0
index a68b1bea57a8..119f820a5a1d 100644

Documentation/userspace-api/index.rst System calls · line 28

Quoted 7 lines
Documentation/userspace-api/index.rst +1 -0
@@ -22,6 +22,7 @@ System calls
    ioctl/index
    mseal
    rseq
+   syscall
 
 Security-related interfaces
 ===========================

It would be more appropriate to name this file mqueue.rst or maybe ipc.rst. This section of index.rst already has a heading of "System calls", so just use a name that tells what system call it is.

Quoted 9 lines
Documentation/userspace-api/syscall.rst new file +3 -0
new file mode 100644
index 000000000000..236c4cb88544
@@ -0,0 +1,273 @@
+mq_timedreceive2 system call
+=============================
+

...

Documentation/userspace-api/syscall.rst line 273

Quoted 5 lines

+8) Concurrent access: verify that simultaneous peek from multiple

Documentation/userspace-api/syscall.rst new file +3 -0
+   threads returns consistent results and does not corrupt queue
+   state. Verify that a concurrent mq_receive() and mq_peek() do
+   not race or oops.
\ No newline at end of file

Add a newline, please.

Signature · 1 line
~Randy
#2 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 next-20260305] [cannot apply to linus/master tip/x86/asm v6.16-rc1]
[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-065614
base:   https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git next
patch link:    https://lore.kernel.org/r/20260305180942.913686-1-academic1mathura%40gmail.com
patch subject: [PATCH] mqueue: introduce new do_mq_timedreceive2() [ mq_peek syscall] for non-destructive receive and inspection,fix minor issue,prepared doc.
config: x86_64-rhel-9.4-func (https://download.01.org/0day-ci/archive/20260306/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260306/[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 >>):

In file included from <command-line>:
ipc/mqueue.c:1748:24: warning: 'struct compat_mq_timedreceive2_args' declared inside parameter list will not be visible outside of this definition or declaration
1748 | struct compat_mq_timedreceive2_args __user *, uargs,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:617:63: note: in definition of macro '__same_type'

     617 | #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
         |                                                               ^
   include/linux/syscalls.h:131:26: note: in expansion of macro '__TYPE_AS'
     131 | #define __TYPE_IS_LL(t) (__TYPE_AS(t, 0LL) || __TYPE_AS(t, 0ULL))
         |                          ^~~~~~~~~
   include/linux/syscalls.h:132:56: note: in expansion of macro '__TYPE_IS_LL'
     132 | #define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
         |                                                        ^~~~~~~~~~~~
   include/linux/syscalls.h:122:27: note: in expansion of macro '__SC_LONG'
     122 | #define __MAP4(m,t,a,...) m(t,a), __MAP3(m,__VA_ARGS__)
         |                           ^
   include/linux/syscalls.h:123:35: note: in expansion of macro '__MAP4'
     123 | #define __MAP5(m,t,a,...) m(t,a), __MAP4(m,__VA_ARGS__)
         |                                   ^~~~~~
   include/linux/syscalls.h:125:22: note: in expansion of macro '__MAP5'
     125 | #define __MAP(n,...) __MAP##n(__VA_ARGS__)
         |                      ^~~~~
   arch/x86/include/asm/syscall_wrapper.h:224:36: note: in expansion of macro '__MAP'
     224 |         static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__));     \
         |                                    ^~~~~
   include/linux/syscalls.h:237:9: note: in expansion of macro '__SYSCALL_DEFINEx'
     237 |         __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:230:36: note: in expansion of macro 'SYSCALL_DEFINEx'
     230 | #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
         |                                    ^~~~~~~~~~~~~~~
   ipc/mqueue.c:1747:1: note: in expansion of macro 'SYSCALL_DEFINE5'
    1747 | SYSCALL_DEFINE5(mq_timedreceive2_time32, mqd_t, mqdes,
         | ^~~~~~~~~~~~~~~
   In file included from ipc/mqueue.c:29:
   ipc/mqueue.c:1748:24: warning: 'struct compat_mq_timedreceive2_args' declared inside parameter list will not be visible outside of this definition or declaration
    1748 |                 struct compat_mq_timedreceive2_args __user *, uargs,
         |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:127:25: note: in definition of macro '__SC_DECL'
     127 | #define __SC_DECL(t, a) t a
         |                         ^
   include/linux/syscalls.h:123:35: note: in expansion of macro '__MAP4'
     123 | #define __MAP5(m,t,a,...) m(t,a), __MAP4(m,__VA_ARGS__)
         |                                   ^~~~~~
   include/linux/syscalls.h:125:22: note: in expansion of macro '__MAP5'
     125 | #define __MAP(n,...) __MAP##n(__VA_ARGS__)
         |                      ^~~~~
   arch/x86/include/asm/syscall_wrapper.h:225:43: note: in expansion of macro '__MAP'
     225 |         static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
         |                                           ^~~~~
   include/linux/syscalls.h:237:9: note: in expansion of macro '__SYSCALL_DEFINEx'
     237 |         __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:230:36: note: in expansion of macro 'SYSCALL_DEFINEx'
     230 | #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
         |                                    ^~~~~~~~~~~~~~~
   ipc/mqueue.c:1747:1: note: in expansion of macro 'SYSCALL_DEFINE5'
    1747 | SYSCALL_DEFINE5(mq_timedreceive2_time32, mqd_t, mqdes,
         | ^~~~~~~~~~~~~~~
   ipc/mqueue.c:1748:24: warning: 'struct compat_mq_timedreceive2_args' declared inside parameter list will not be visible outside of this definition or declaration
    1748 |                 struct compat_mq_timedreceive2_args __user *, uargs,
         |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler_types.h:617:63: note: in definition of macro '__same_type'
     617 | #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
         |                                                               ^
   include/linux/syscalls.h:131:26: note: in expansion of macro '__TYPE_AS'
     131 | #define __TYPE_IS_LL(t) (__TYPE_AS(t, 0LL) || __TYPE_AS(t, 0ULL))
         |                          ^~~~~~~~~
   include/linux/syscalls.h:132:56: note: in expansion of macro '__TYPE_IS_LL'
     132 | #define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
         |                                                        ^~~~~~~~~~~~
   include/linux/syscalls.h:122:27: note: in expansion of macro '__SC_LONG'
     122 | #define __MAP4(m,t,a,...) m(t,a), __MAP3(m,__VA_ARGS__)
         |                           ^
   include/linux/syscalls.h:123:35: note: in expansion of macro '__MAP4'
     123 | #define __MAP5(m,t,a,...) m(t,a), __MAP4(m,__VA_ARGS__)
         |                                   ^~~~~~
   include/linux/syscalls.h:125:22: note: in expansion of macro '__MAP5'
     125 | #define __MAP(n,...) __MAP##n(__VA_ARGS__)
         |                      ^~~~~
   arch/x86/include/asm/syscall_wrapper.h:228:36: note: in expansion of macro '__MAP'
     228 |         static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__))      \
         |                                    ^~~~~
   include/linux/syscalls.h:237:9: note: in expansion of macro '__SYSCALL_DEFINEx'
     237 |         __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:230:36: note: in expansion of macro 'SYSCALL_DEFINEx'
     230 | #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
         |                                    ^~~~~~~~~~~~~~~
   ipc/mqueue.c:1747:1: note: in expansion of macro 'SYSCALL_DEFINE5'
    1747 | SYSCALL_DEFINE5(mq_timedreceive2_time32, mqd_t, mqdes,
         | ^~~~~~~~~~~~~~~
   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 [-Wincompatible-pointer-types]
     133 | #define __SC_CAST(t, a) (__force t) a
   include/linux/syscalls.h:122:27: note: in expansion of macro '__SC_CAST'
     122 | #define __MAP4(m,t,a,...) m(t,a), __MAP3(m,__VA_ARGS__)
         |                           ^
   include/linux/syscalls.h:123:35: note: in expansion of macro '__MAP4'
     123 | #define __MAP5(m,t,a,...) m(t,a), __MAP4(m,__VA_ARGS__)
         |                                   ^~~~~~
   include/linux/syscalls.h:125:22: note: in expansion of macro '__MAP5'
     125 | #define __MAP(n,...) __MAP##n(__VA_ARGS__)
         |                      ^~~~~
   arch/x86/include/asm/syscall_wrapper.h:230:43: note: in expansion of macro '__MAP'
     230 |                 long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__));\
         |                                           ^~~~~
   include/linux/syscalls.h:237:9: note: in expansion of macro '__SYSCALL_DEFINEx'
     237 |         __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:230:36: note: in expansion of macro 'SYSCALL_DEFINEx'
     230 | #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
         |                                    ^~~~~~~~~~~~~~~
   ipc/mqueue.c:1747:1: note: in expansion of macro 'SYSCALL_DEFINE5'
    1747 | SYSCALL_DEFINE5(mq_timedreceive2_time32, mqd_t, mqdes,
         | ^~~~~~~~~~~~~~~
   ipc/mqueue.c:1748:63: note: expected 'struct compat_mq_timedreceive2_args *' but argument is of type 'struct compat_mq_timedreceive2_args *'
    1748 |                 struct compat_mq_timedreceive2_args __user *, uargs,
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
   include/linux/syscalls.h:127:27: note: in definition of macro '__SC_DECL'
     127 | #define __SC_DECL(t, a) t a
         |                           ^
   include/linux/syscalls.h:123:35: note: in expansion of macro '__MAP4'
     123 | #define __MAP5(m,t,a,...) m(t,a), __MAP4(m,__VA_ARGS__)
         |                                   ^~~~~~
   include/linux/syscalls.h:125:22: note: in expansion of macro '__MAP5'
     125 | #define __MAP(n,...) __MAP##n(__VA_ARGS__)
         |                      ^~~~~
   arch/x86/include/asm/syscall_wrapper.h:225:43: note: in expansion of macro '__MAP'
     225 |         static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
         |                                           ^~~~~
   include/linux/syscalls.h:237:9: note: in expansion of macro '__SYSCALL_DEFINEx'
     237 |         __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:230:36: note: in expansion of macro 'SYSCALL_DEFINEx'
     230 | #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
         |                                    ^~~~~~~~~~~~~~~
   ipc/mqueue.c:1747:1: note: in expansion of macro 'SYSCALL_DEFINE5'
    1747 | SYSCALL_DEFINE5(mq_timedreceive2_time32, mqd_t, mqdes,
         | ^~~~~~~~~~~~~~~
   ipc/mqueue.c: At top level:
   ipc/mqueue.c:1748:24: warning: 'struct compat_mq_timedreceive2_args' declared inside parameter list will not be visible outside of this definition or declaration
    1748 |                 struct compat_mq_timedreceive2_args __user *, uargs,
         |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:127:25: note: in definition of macro '__SC_DECL'
     127 | #define __SC_DECL(t, a) t a
         |                         ^
   include/linux/syscalls.h:123:35: note: in expansion of macro '__MAP4'
     123 | #define __MAP5(m,t,a,...) m(t,a), __MAP4(m,__VA_ARGS__)
         |                                   ^~~~~~
   include/linux/syscalls.h:125:22: note: in expansion of macro '__MAP5'
     125 | #define __MAP(n,...) __MAP##n(__VA_ARGS__)
         |                      ^~~~~
   arch/x86/include/asm/syscall_wrapper.h:235:43: note: in expansion of macro '__MAP'
     235 |         static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
         |                                           ^~~~~
   include/linux/syscalls.h:237:9: note: in expansion of macro '__SYSCALL_DEFINEx'
     237 |         __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:230:36: note: in expansion of macro 'SYSCALL_DEFINEx'
     230 | #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
         |                                    ^~~~~~~~~~~~~~~
   ipc/mqueue.c:1747:1: note: in expansion of macro 'SYSCALL_DEFINE5'
    1747 | 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/x86/include/asm/syscall_wrapper.h:235:28: error: conflicting types for '__do_sys_mq_timedreceive2_time32'; have 'long int(mqd_t,  struct compat_mq_timedreceive2_args *, unsigned int,  const long unsigned int,  const struct old_timespec32 *)' {aka 'long int(int,  struct compat_mq_timedreceive2_args *, unsigned int,  const long unsigned int,  const struct old_timespec32 *)'}
     235 |         static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
         |                            ^~~~~~~~
   include/linux/syscalls.h:237:9: note: in expansion of macro '__SYSCALL_DEFINEx'
     237 |         __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:230:36: note: in expansion of macro 'SYSCALL_DEFINEx'
     230 | #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
         |                                    ^~~~~~~~~~~~~~~
   ipc/mqueue.c:1747:1: note: in expansion of macro 'SYSCALL_DEFINE5'
    1747 | SYSCALL_DEFINE5(mq_timedreceive2_time32, mqd_t, mqdes,
         | ^~~~~~~~~~~~~~~
   arch/x86/include/asm/syscall_wrapper.h:225:28: note: previous declaration of '__do_sys_mq_timedreceive2_time32' with type 'long int(mqd_t,  struct compat_mq_timedreceive2_args *, unsigned int,  const long unsigned int,  const struct old_timespec32 *)' {aka 'long int(int,  struct compat_mq_timedreceive2_args *, unsigned int,  const long unsigned int,  const struct old_timespec32 *)'}
     225 |         static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
         |                            ^~~~~~~~
   include/linux/syscalls.h:237:9: note: in expansion of macro '__SYSCALL_DEFINEx'
     237 |         __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:230:36: note: in expansion of macro 'SYSCALL_DEFINEx'
     230 | #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
         |                                    ^~~~~~~~~~~~~~~
   ipc/mqueue.c:1747:1: note: in expansion of macro 'SYSCALL_DEFINE5'
    1747 | SYSCALL_DEFINE5(mq_timedreceive2_time32, mqd_t, mqdes,
         | ^~~~~~~~~~~~~~~
   ipc/mqueue.c: In function '__do_sys_mq_timedreceive2_time32':
>> ipc/mqueue.c:1756:13: error: implicit declaration of function 'get_compat_mq_args'; did you mean 'get_compat_msghdr'? [-Wimplicit-function-declaration]
    1756 |         if (get_compat_mq_args(pargs, uargs))
         |             ^~~~~~~~~~~~~~~~~~
         |             get_compat_msghdr
   ipc/mqueue.c: At top level:
   arch/x86/include/asm/syscall_wrapper.h:225:28: warning: '__do_sys_mq_timedreceive2_time32' used but never defined
     225 |         static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
         |                            ^~~~~~~~
   include/linux/syscalls.h:237:9: note: in expansion of macro '__SYSCALL_DEFINEx'
     237 |         __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:230:36: note: in expansion of macro 'SYSCALL_DEFINEx'
     230 | #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
         |                                    ^~~~~~~~~~~~~~~
   ipc/mqueue.c:1747:1: note: in expansion of macro 'SYSCALL_DEFINE5'
    1747 | SYSCALL_DEFINE5(mq_timedreceive2_time32, mqd_t, mqdes,
         | ^~~~~~~~~~~~~~~

vim +/__do_sys_mq_timedreceive2_time32 +133 include/linux/syscalls.h

07fe6e00f6cca6f Al Viro            2013-01-21  126  
07fe6e00f6cca6f Al Viro            2013-01-21  127  #define __SC_DECL(t, a)	t a
4f59c718521a0f0 Al Viro            2017-07-08  128  #define __TYPE_AS(t, v)	__same_type((__force t)0, v)
4f59c718521a0f0 Al Viro            2017-07-08  129  #define __TYPE_IS_L(t)	(__TYPE_AS(t, 0L))
4f59c718521a0f0 Al Viro            2017-07-08  130  #define __TYPE_IS_UL(t)	(__TYPE_AS(t, 0UL))
4f59c718521a0f0 Al Viro            2017-07-08  131  #define __TYPE_IS_LL(t) (__TYPE_AS(t, 0LL) || __TYPE_AS(t, 0ULL))
4a0fd5bf0fd0795 Al Viro            2013-01-21  132  #define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
4f59c718521a0f0 Al Viro            2017-07-08 @133  #define __SC_CAST(t, a)	(__force t) a
56062d60f117dcc Richard Palethorpe 2024-01-10  134  #define __SC_TYPE(t, a)	t
2cf0966683430b6 Al Viro            2013-01-21  135  #define __SC_ARGS(t, a)	a
4a0fd5bf0fd0795 Al Viro            2013-01-21  136  #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
1a94bc34768e463 Heiko Carstens     2009-01-14  137  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki