Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965284AbcKXLdj convert rfc822-to-8bit (ORCPT ); Thu, 24 Nov 2016 06:33:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54054 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964851AbcKXLdh (ORCPT ); Thu, 24 Nov 2016 06:33:37 -0500 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: References: <147997746306.9316.227351186233378585.stgit@warthog.procyon.org.uk> <147997747766.9316.11606802798600210253.stgit@warthog.procyon.org.uk> <5323.1479986239@warthog.procyon.org.uk> To: Andrey Ryabinin Cc: dhowells@redhat.com, jmorris@namei.org, Dmitry Kasatkin , LKML , stable@vger.kernel.org, linux-security-module@vger.kernel.org, keyrings@vger.kernel.org, linux-ima-devel@lists.sourceforge.net Subject: Re: [PATCH 2/2] MPI: Fix mpi_powm() when exponent is 0 and the result has no limbs MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <5806.1479987214.1@warthog.procyon.org.uk> Content-Transfer-Encoding: 8BIT Date: Thu, 24 Nov 2016 11:33:34 +0000 Message-ID: <5807.1479987214@warthog.procyon.org.uk> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 24 Nov 2016 11:33:37 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 734 Lines: 24 Andrey Ryabinin wrote: > > David Howells wrote: > > > >> + if (!rp) { > >> + if (mpi_resize(res, 1) < 0) > > > > This is better done with RESIZE_IF_NEEDED(). > > > > mpi_resize() is equal to RESIZE_IF_NEEDED(), it also checks for allocated space: > > int mpi_resize(MPI a, unsigned nlimbs) > { > .... > if (nlimbs <= a->alloced) > return 0; /* no need to do it */ Hmmm... In that case, should your patch use mpi_resize() rather than RESIZE_IF_NEEDED()? It's a trivial case that we should perhaps weed out much earlier (ie. reject the key if exp<2 or mod<2), but it would make the object file slightly smaller not to do the test twice. David