summaryrefslogtreecommitdiff
path: root/sys/kern/sys_mqueue.c
diff options
context:
space:
mode:
authorkamil <kamil@NetBSD.org>2018-07-04 17:39:12 +0000
committerkamil <kamil@NetBSD.org>2018-07-04 17:39:12 +0000
commit48bbf57b25c8694489ce0e1aed9f04056d98ce9d (patch)
tree44cf53cd54499635436c398af148ad25a56a29bf /sys/kern/sys_mqueue.c
parent993b8fb9080d314daa248f568a85243663aeb576 (diff)
Avoid undefined behavior in mq_recv1()
Do not shift a signed integer causing change of the signed bit. sys/kern/sys_mqueue.c:712:24, left shift of 1 by 31 places cannot be represented in type 'int' Detected with Kernel Undefined Behavior Sanitizer. Reported by <Harry Pantazis>
Diffstat (limited to 'sys/kern/sys_mqueue.c')
-rw-r--r--sys/kern/sys_mqueue.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/kern/sys_mqueue.c b/sys/kern/sys_mqueue.c
index c5ff7911699..2ff668dbe98 100644
--- a/sys/kern/sys_mqueue.c
+++ b/sys/kern/sys_mqueue.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_mqueue.c,v 1.40 2017/11/30 20:25:55 christos Exp $ */
+/* $NetBSD: sys_mqueue.c,v 1.41 2018/07/04 17:39:12 kamil Exp $ */
/*
* Copyright (c) 2007-2011 Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.40 2017/11/30 20:25:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.41 2018/07/04 17:39:12 kamil Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -709,7 +709,7 @@ mq_recv1(mqd_t mqdes, void *msg_ptr, size_t msg_len, u_int *msg_prio,
/* Unmark the bit, if last message. */
if (__predict_true(idx) && TAILQ_EMPTY(&mq->mq_head[idx])) {
KASSERT((MQ_PQSIZE - idx) == msg->msg_prio);
- mq->mq_bitmap &= ~(1 << --idx);
+ mq->mq_bitmap &= ~(1U << --idx);
}
/* Decrement the counter and signal waiter, if any */