Re: [PATCH RESEND v2 1/4]IPC: Added New system call do_mq_timedreceive2() for non-destructive peek on posix mqueue

From: Jonathan Corbet

Date: Tue Mar 31 2026 - 12:27:25 EST


One other thing I noticed ...

Mathura_Kumar <academic1mathura@xxxxxxxxx> writes:

> Signed-off-by: Mathura_Kumar <academic1mathura@xxxxxxxxx>
> ---
> include/linux/compat.h | 6 +-
> include/linux/syscalls.h | 6 +
> include/uapi/asm-generic/unistd.h | 7 +-
> include/uapi/linux/mqueue.h | 14 ++-
> ipc/mqueue.c | 186 ++++++++++++++++++++++++++++--
> ipc/msg.c | 2 +-
> ipc/msgutil.c | 48 ++++----
> ipc/util.h | 3 +-
> kernel/sys_ni.c | 1 +
> 9 files changed, 231 insertions(+), 42 deletions(-)

[...]

> +static int do_mq_timedreceive2(mqd_t mqdes, struct mq_timedreceive2_args *args,
> + unsigned int flags, unsigned long index,
> + struct timespec64 *ts)
> +{
> + ssize_t ret;
> + struct msg_msg *msg_ptr, *k_msg_buffer;
> + long k_m_type;
> + size_t k_m_ts;
> + struct inode *inode;
> + struct mqueue_inode_info *info;
> +
> + if (!(flags & MQ_PEEK)) {
> + return do_mq_timedreceive(mqdes, args->msg_ptr, args->msg_len,
> + args->msg_prio, ts);
> + }

You don't check for unknown flags here; that will make impossible to add
new flags in the future.

jon