Received: by 10.213.65.68 with SMTP id h4csp484915imn; Fri, 16 Mar 2018 09:09:22 -0700 (PDT) X-Google-Smtp-Source: AG47ELvi19PbU9N8MKD7ZVtpLPKanCsgrNAS+KKtOvG33sPzI+zPWevb1EdQJ5QR9AiRz62Kuamw X-Received: by 10.98.15.137 with SMTP id 9mr2030104pfp.216.1521216562467; Fri, 16 Mar 2018 09:09:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521216562; cv=none; d=google.com; s=arc-20160816; b=foFSmDt/yu+0nq+Xaq0iH+bIX3/X96hNXZyjYUP2WUEVviPXUarybIBYsMMQrnzHH8 WFEegwiGoa9w1ATvvxeFYiuPfnzlBM3c+P32K3+sOUjCNcFb827FPHIRYY7UksN8B4Sg jQrW0x/mZP3Qb2gQaIcSMW4hUCZVtSp03tt9RmTYvMYDCEik1rhcrAezy0D5/A5Md115 VlKnoX7+IGo16EmJ3GfQcf6n1dx062M73GHAF8TB56Tl4MR30FU5GWC+x/SUuBFnsEn/ cK4d381Luxr+1rqh+hHz58WDpVJc1yYQmKPRKPvVtdiKRFwi4rnIHQv+GBaESLcTZm7G R5aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=vBYzg1bJNIS0KASnz3M3LslSLgu3dh2llWhjABXH4Ic=; b=hl5kB6d8tLkdZ3PZxIJG+jc4b6XjTFvpTr/nprY+s270xWT1zNH8qhdBOLvvV1amnL XrbyQBFwZe769iJli4rN8KkpUfwLZn8GAO2wD8Drzv3KWH6qicaLw6af5TkXJmty8e1m XKzp2T7iZFUjSuA5sXHBNdmle2zTyzKWx/U+pTbhSiTsyJizg1ZY44VGor9ypfFAX+P8 hBOLX5K9LghGT/foRMhmZ2cnAvXsS4ZTXNS4gkrqkF/VOPRxfB3ttTGDN+C4/aqBaEeH TiyRHtgwNG8JvB6quQ3y6SW/9miIbBaVpD92qTQL/w9tgCIBQCMh+Z4J9q2+n7vRCnBR J6cQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o61-v6si6252771pld.692.2018.03.16.09.09.08; Fri, 16 Mar 2018 09:09:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754769AbeCPQII (ORCPT + 99 others); Fri, 16 Mar 2018 12:08:08 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43884 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754689AbeCPPlO (ORCPT ); Fri, 16 Mar 2018 11:41:14 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6CFE9EE4; Fri, 16 Mar 2018 15:41:13 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pierre Ducroquet , PrasannaKumar Muralidharan , Herbert Xu , Sasha Levin Subject: [PATCH 4.15 049/128] crypto: ecc - Fix NULL pointer deref. on no default_rng Date: Fri, 16 Mar 2018 16:23:10 +0100 Message-Id: <20180316152339.283206824@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152336.199007505@linuxfoundation.org> References: <20180316152336.199007505@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pierre [ Upstream commit 4c0e22c90510308433272d7ba281b1eb4eda8209 ] If crypto_get_default_rng returns an error, the function ecc_gen_privkey should return an error. Instead, it currently tries to use the default_rng nevertheless, thus creating a kernel panic with a NULL pointer dereference. Returning the error directly, as was supposedly intended when looking at the code, fixes this. Signed-off-by: Pierre Ducroquet Reviewed-by: PrasannaKumar Muralidharan Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- crypto/ecc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/crypto/ecc.c +++ b/crypto/ecc.c @@ -964,7 +964,7 @@ int ecc_gen_privkey(unsigned int curve_i * DRBG with a security strength of 256. */ if (crypto_get_default_rng()) - err = -EFAULT; + return -EFAULT; err = crypto_rng_get_bytes(crypto_default_rng, (u8 *)priv, nbytes); crypto_put_default_rng();