Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759693AbcJ1TWe (ORCPT ); Fri, 28 Oct 2016 15:22:34 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34310 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754925AbcJ1TWd (ORCPT ); Fri, 28 Oct 2016 15:22:33 -0400 Subject: Re: [PATCH] ipc/sem: ensure we left shift a ULL rather than a 32 bit integer To: Colin King , Andrew Morton , Davidlohr Bueso , Peter Zijlstra , Ingo Molnar , Nikolay Borisov References: <20161028181129.7311-1-colin.king@canonical.com> Cc: linux-kernel@vger.kernel.org From: Manfred Spraul Message-ID: <8570d3d4-aeaf-7d2e-7d04-3234264959fd@colorfullife.com> Date: Fri, 28 Oct 2016 21:21:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161028181129.7311-1-colin.king@canonical.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 974 Lines: 31 Hi Colin, On 10/28/2016 08:11 PM, Colin King wrote: > From: Colin Ian King > > 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. Good catch, thanks. > CoverityScan CID#1372862 "Bad bit shift operation" > > Fixes: 7c24530cb4e3c0ae ("ipc/sem: optimize perform_atomic_semop()") > Signed-off-by: Colin Ian King > --- > 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); > Why 1ULL? Is 1UL not sufficient? -- Manfred