[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9150.1509545421@warthog.procyon.org.uk>
Date: Wed, 01 Nov 2017 14:10:21 +0000
From: David Howells <dhowells@...hat.com>
To: Ayush Mittal <ayush.m@...sung.com>
Cc: dhowells@...hat.com, aryabinin@...tuozzo.com,
james.l.morris@...cle.com, linux-kernel@...r.kernel.org,
v.narang@...sung.com, a.sahrawat@...sung.com, pankaj.m@...sung.com
Subject: Re: [PATCH 1/1] mpi: check for shift exponent greater than 31.
Ayush Mittal <ayush.m@...sung.com> 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
Powered by blists - more mailing lists