Received: by 10.213.65.68 with SMTP id h4csp505403imn; Fri, 16 Mar 2018 09:47:51 -0700 (PDT) X-Google-Smtp-Source: AG47ELurOYDRvbvtPlukjET7XxWy0uJEMXIzDSEcRb06R8lrgItp/UT2GGtquec21c9aruXJa/jz X-Received: by 2002:a17:902:1665:: with SMTP id g92-v6mr2777631plg.195.1521218871170; Fri, 16 Mar 2018 09:47:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521218871; cv=none; d=google.com; s=arc-20160816; b=fo8R3NWqEGvt5bGC1D3mOsq4nB9+gvZj8bg0O5cruWfSMQGZVV4YzaLfHiz6BDI8b9 je04VZ8ZIHqUif8SRNEm1pyg5stuNON1Tf7G1ms4qolBWXnnBzxXgf48oRfN/kJhoF1V AkM5dkNQW8jRZIdK7SvsYkJOI+/T7QNgr1MqfFHhVKDD2yjo6nrxN4PP288tEkYgJXWv b0EeG3h2dsf8uAYPPecROy/zOGj/W1vyovfTiJynMGg/JDq1VCVzyICYHKjlUIgFYDIL Egac7uLn4NjCz+uoQ1pPaDoaA4YTgRKOhPkpHm0psWWGnWCixbcJvlJ0jMgofdiVkAa4 o1Qg== 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=HQv/LtyifTYPNNaAUeh5X0ghgGSEkBLfiQJk07UIKyA=; b=yz14c7f4kKf/aoG0xXpiBuvwJ3PTxQ9bJs4EFy5vgkLWeh22EfcRWpuahMiDr4GbdN ynlkogXEvlP6yrxRm3tnZTDt0IqIXdl8HPin1MAQaQCwsyrEmmx2aaJjiycWtGc5jxT8 iR/UHvJQuM36qvCqzLAM0Qy+myVS2e6z0xiuRaitu2SZ2N14IoTxqhvGDbbV0PrLW2Jk Rvl20aF4aDfhNNlKy+4AYMCeV/RVOxrEnjb8pUKNw11Sd5K4yZ23XvCBomOrjQsnPyz1 /6sdSoDlGWRW4wHoh4vpIgSUb/g9y0vI01ZmnevUIoT//vXCh0Jg6jwkz1TKC4Bf7EBs qNZQ== 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 p24si4659148pgn.797.2018.03.16.09.47.36; Fri, 16 Mar 2018 09:47:51 -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 S1753305AbeCPQqA (ORCPT + 99 others); Fri, 16 Mar 2018 12:46:00 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:39890 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934164AbeCPPfg (ORCPT ); Fri, 16 Mar 2018 11:35:36 -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 31833D4F; Fri, 16 Mar 2018 15:35:36 +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.14 042/109] crypto: ecc - Fix NULL pointer deref. on no default_rng Date: Fri, 16 Mar 2018 16:23:11 +0100 Message-Id: <20180316152332.238232657@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152329.844663293@linuxfoundation.org> References: <20180316152329.844663293@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.14-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();