From patchwork Wed Sep 30 13:01:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 11809037 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 53FFE618 for ; Wed, 30 Sep 2020 13:01:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4606020709 for ; Wed, 30 Sep 2020 13:01:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730034AbgI3NBe (ORCPT ); Wed, 30 Sep 2020 09:01:34 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:39346 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725771AbgI3NBc (ORCPT ); Wed, 30 Sep 2020 09:01:32 -0400 Received: from cpc154979-craw9-2-0-cust193.16-3.cable.virginm.net ([80.193.200.194] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kNbjY-0008WT-BG; Wed, 30 Sep 2020 13:01:24 +0000 From: Colin King To: Andrew Morton , Johannes Weiner , Herbert Xu , Tianjia Zhang , Waiman Long Cc: kernel-janitors@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next][resend] lib/mpi: fix off-by-one check on index "no" Date: Wed, 30 Sep 2020 14:01:23 +0100 Message-Id: <20200930130123.8064-1-colin.king@canonical.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Colin Ian King There is an off-by-one range check on the upper limit of index "no". Fix this by changing the > comparison to >= Addresses-Coverity: ("Out-of-bounds read") Fixes: a8ea8bdd9df9 ("lib/mpi: Extend the MPI library") Signed-off-by: Colin Ian King --- resend to Cc linux-crypto --- lib/mpi/mpiutil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mpi/mpiutil.c b/lib/mpi/mpiutil.c index 3c63710c20c6..632d0a4bf93f 100644 --- a/lib/mpi/mpiutil.c +++ b/lib/mpi/mpiutil.c @@ -69,7 +69,7 @@ postcore_initcall(mpi_init); */ MPI mpi_const(enum gcry_mpi_constants no) { - if ((int)no < 0 || no > MPI_NUMBER_OF_CONSTANTS) + if ((int)no < 0 || no >= MPI_NUMBER_OF_CONSTANTS) pr_err("MPI: invalid mpi_const selector %d\n", no); if (!constants[no]) pr_err("MPI: MPI subsystem not initialized\n");