From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754649AbdKAOK1 (ORCPT ); Wed, 1 Nov 2017 10:10:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54362 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752297AbdKAOKZ (ORCPT ); Wed, 1 Nov 2017 10:10:25 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9C28233A191 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dhowells@redhat.com Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <1508822823-31231-1-git-send-email-ayush.m@samsung.com> References: <1508822823-31231-1-git-send-email-ayush.m@samsung.com> To: Ayush Mittal Cc: dhowells@redhat.com, aryabinin@virtuozzo.com, james.l.morris@oracle.com, linux-kernel@vger.kernel.org, v.narang@samsung.com, a.sahrawat@samsung.com, pankaj.m@samsung.com Subject: Re: [PATCH 1/1] mpi: check for shift exponent greater than 31. MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <9149.1509545421.1@warthog.procyon.org.uk> Date: Wed, 01 Nov 2017 14:10:21 +0000 Message-ID: <9150.1509545421@warthog.procyon.org.uk> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 01 Nov 2017 14:10:25 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ayush Mittal wrote: > This patch check for shift exponent greater than 31, Firstly, isn't it 63 on 64-bit machines? Secondly, this is the wrong way to do things. The banner comment on mpihelp_lshift(), for example, says that the function has the following argument constraints: 0 < CNT < BITS_PER_MP_LIMB so sh1 and sh2 must both be in the range 1-31 or 1-63, assuming cnt is within its constraints. Therefore if it needs a checking, you only need to check cnt on entry to the function, rather than checking sh1 and sh2 inside the loop. Further, you should use pr_err() so that we know that this has gone wrong and return an error to the caller (there are security implications). Further, have you checked the caller to see if they do ever violate the constraints? It looks like you're adding fixes for your test, not for the code. David