Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2486241rwb; Fri, 16 Dec 2022 02:45:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf7lDQcNbiUtr96t2X3ZhYg948qf9fzpoVyit6Xys/Y/3XxyYE9OhZCKze2k+jcfv9kBay9t X-Received: by 2002:a17:906:86ca:b0:7c0:f2cf:23fb with SMTP id j10-20020a17090686ca00b007c0f2cf23fbmr28339620ejy.52.1671187520530; Fri, 16 Dec 2022 02:45:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671187520; cv=none; d=google.com; s=arc-20160816; b=WQFh3v8q+6u5Or520MRLpYd4zvNIx+WQKM62qpGo4qqP/M36V1MqRSja4rJNaPHii1 y1wR3NaTgfhy8AHLI3179tYRavDfo1vHuLh3zsw4weQA64A6X3aJKdcZwHFHENGJfe94 VplKC8f5Pii6vPgA5CzC7WC/S+fv8GJTtPPv0cJwll/X5qaJpa1OtIdH7ZwXvaNp+57V K1+oeGjITtx8XIihD3S4n+Qz16D06Za6uiG1YhRmPdm4/5ZRfz3NUPo7OQfrgA3t5IbR IIZj1YWf2KRGHXHiat5YNpxMwFnk9jo+qcF9aD3J/+qp78arfzhl34gxPuUkNt1EEFCP fPzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=nA1HgAm2qVjlkyZ03/ymROJs0AjG3Y60d+MwNcPBH5g=; b=Obzd+pR7S3kkRl4nY4X3uIwRBcjeNoFp4h2oBQJ5Wm5rOg08yJsfZkFfByHrQBQ70L MxM4W6D5QCOZRpv+EguuXXdtnu5vJSaHvbgRgQA6TWyNDl3utPURrFwgxK2FdjwNJYwc 8hitIUxQzMpJNk+nij+FQDgZKkf55oqMi53QzYO1iyT5EB05biWUxq+r2j8tJr+O+Rt4 ut62A+nDOEGWkvLEe4kd1WvDDkCGI4R0OkCqm89lN/HjdMapHZ30RSFj2TmkBcCXFRP+ arJaeRIGgnAlehzDLaZ2eriv5e1xkyKMESBdds9GGAT/yrmdYlUGlUwrNwDYzVCND7iF Kz+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NluIm6tj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr15-20020a1709073f8f00b007c4f6c371a8si2251984ejc.519.2022.12.16.02.45.04; Fri, 16 Dec 2022 02:45:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NluIm6tj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230115AbiLPJQV (ORCPT + 68 others); Fri, 16 Dec 2022 04:16:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbiLPJQT (ORCPT ); Fri, 16 Dec 2022 04:16:19 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEC6829CA5; Fri, 16 Dec 2022 01:16:17 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 54B3761F58; Fri, 16 Dec 2022 09:16:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE0FAC433EF; Fri, 16 Dec 2022 09:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671182176; bh=LQ6WvU/8VYqSkymhRGk1M2D2cUZNcEEJNASg72U+chI=; h=From:To:Cc:Subject:Date:From; b=NluIm6tjLFbZNvYdy96AFVqdQT5NtNGdq5Mjn0NZ+eBB6pkCdPBtei86AVcdpIhMK fTtzB6lZTDNJtYPtFOH0zT7Ci5CcHk1Kf49fX06LRh/PKaQx+yfkOY1vhy96ciR9wi P7mN94QuOX2BowB5KiqrtXf6NTG+Rv0G8Ea/VtIjvVv253t2HPbd7CI2fCHsBtwvdG VOs8+M0Fhxuh380DuclnDF0TNMiPuf2a8JyZ37tlbBI5c1wY40REqf+rLCXAqZRmeh HwVpxo983Ap2Z2CbwaEejGHudCmXwoHykMVIr5fLPx5cTV9wDqDYT+RtEHJPVHopb7 FIWicAS0T5wag== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p66pl-0001ei-IZ; Fri, 16 Dec 2022 10:16:50 +0100 From: Johan Hovold To: Ard Biesheuvel Cc: "Jason A. Donenfeld" , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , Steev Klimaszewski , Bjorn Andersson Subject: [PATCH] efi: random: fix NULL-deref when refreshing seed Date: Fri, 16 Dec 2022 10:15:14 +0100 Message-Id: <20221216091514.6298-1-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Do not try to refresh the RNG seed in case the firmware does not support setting variables. This is specifically needed to prevent a NULL-pointer dereference on the Lenovo X13s with some firmware revisions. Fixes: e7b813b32a42 ("efi: random: refresh non-volatile random seed when RNG is initialized") Reported-by: Steev Klimaszewski Reported-by: Bjorn Andersson Signed-off-by: Johan Hovold --- drivers/firmware/efi/efi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 2e168e5b97de..1a9e2f70c550 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -432,7 +432,9 @@ static int __init efisubsys_init(void) platform_device_register_simple("efi_secret", 0, NULL, 0); #endif - execute_with_initialized_rng(&refresh_nv_rng_seed_nb); + if (efi_rt_services_supported(EFI_RT_SUPPORTED_SET_VARIABLE)) + execute_with_initialized_rng(&refresh_nv_rng_seed_nb); + return 0; err_remove_group: -- 2.37.4