Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1511324

[PATCH] ipc/sem: ensure we left shift a ULL rather than a 32 bit integer

From Colin King <colin.king@canonical.com>
Newsgroups linux.kernel
Subject [PATCH] ipc/sem: ensure we left shift a ULL rather than a 32 bit integer
Date 2016-10-28 20:20 +0200
Message-ID <sxjUZ-3o4-7@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


From: Colin Ian King <colin.king@canonical.com>

The left shift amount is sop->sem_num % 64, which is up to 63, so
ensure we are shifting a ULL rather than a 32 bit value.

CoverityScan CID#1372862 "Bad bit shift operation"

Fixes: 7c24530cb4e3c0ae ("ipc/sem: optimize perform_atomic_semop()")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 ipc/sem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipc/sem.c b/ipc/sem.c
index ebd18a7..ca4aa23 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1839,7 +1839,7 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
 
 	max = 0;
 	for (sop = sops; sop < sops + nsops; sop++) {
-		unsigned long mask = 1 << ((sop->sem_num) % BITS_PER_LONG);
+		unsigned long mask = 1ULL << ((sop->sem_num) % BITS_PER_LONG);
 
 		if (sop->sem_num >= max)
 			max = sop->sem_num;
-- 
2.9.3

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[PATCH] ipc/sem: ensure we left shift a ULL rather than a 32 bit integer Colin King <colin.king@canonical.com> - 2016-10-28 20:20 +0200
  Re: [PATCH] ipc/sem: ensure we left shift a ULL rather than a 32 bit  integer Colin Ian King <colin.king@canonical.com> - 2016-10-28 21:30 +0200
    Re: [PATCH] ipc/sem: ensure we left shift a ULL rather than a 32 bit  integer Manfred Spraul <manfred@colorfullife.com> - 2016-10-30 16:40 +0100
  Re: [PATCH] ipc/sem: ensure we left shift a ULL rather than a 32 bit  integer Manfred Spraul <manfred@colorfullife.com> - 2016-10-28 21:30 +0200
  Re: [PATCH] ipc/sem: ensure we left shift a ULL rather than a 32 bit  integer Davidlohr Bueso <dave@stgolabs.net> - 2016-10-29 00:20 +0200

csiph-web