Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp2638069rwj; Mon, 19 Dec 2022 07:08:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf49wTk22bNAmlWJsDqQ+Ib5emXg7SguUOPJs+GF8/Jv4DpbTR/SV1UuFzILctktveChYzhB X-Received: by 2002:a05:6402:3644:b0:461:2288:6808 with SMTP id em4-20020a056402364400b0046122886808mr37603843edb.21.1671462484728; Mon, 19 Dec 2022 07:08:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671462484; cv=none; d=google.com; s=arc-20160816; b=SwMA33HCVydP6wXq3x7LXsabIqEwZgkCOsVsXCK+4KQB2mq66o2dHiULroEwKmKajD qtQ6QGEg+hh+pVV0U4X8i7kJuOZffCcQ3DyiX6WO+frZtaY5iPLV5NTuNcOj202GGjoA 5rIRZ6zqu04ObeUuXrMPq6QFqe1FB3yD0vVpA6KT+JDbqTAUch8xukXCoz3fF+0CvZoW D67M/XU7GW2lOyDfamjH/xOq3Uqu74H4jq1GG3ezmSS0N1b30d6f4IHN1xoJ91PY15OA j9YwpiTmfmeViC1k5vl2JAn2DKgvfYzZS2xbMWoSNQI0gu9GKAgPma2r/RaGfLh2a294 Iu4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ua8Y8Z4pBPkKAQrNbMtdprGt9Mnzjiq5jD7V9dAC+Y0=; b=upjtuxMSF3f3g29w0z4RmBA7uo2FnP6bKKDZVYfa5rpjjyGOpcCq1c0TEUf1x3YmlG MUMu62haXWuiEozhiqaHLfK17HF+z7x9WRB5SexqQvXneIMj0XhxPlB47/AZIEdQ78a7 B8rp2CaplmIxbHW9/OWw+c3GNEO7hC/GbqUa0iQAN/E3P+Dw9xMMLg/r4YUK00TRtI8b WkQ6pPCE3TtMzmS0ju3sbA3IhlRyyxCKnFop5+eeSQYPxFQw32pow7CJcB1Dtf0jw/7R DRUZpnDU4lhlGX8hpIANbvlXzpzpYjz+MHNB4LlIowmM1V5Ukm+tTUGYsaDevHC0uwpt +nyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kali.org header.s=google header.b=G3jXAcTB; 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=kali.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ee53-20020a056402293500b0046a8fe6d173si7652239edb.456.2022.12.19.07.07.47; Mon, 19 Dec 2022 07:08:04 -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=@kali.org header.s=google header.b=G3jXAcTB; 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=kali.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231516AbiLSOkV (ORCPT + 72 others); Mon, 19 Dec 2022 09:40:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231370AbiLSOkR (ORCPT ); Mon, 19 Dec 2022 09:40:17 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 064728F for ; Mon, 19 Dec 2022 06:40:16 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id a16so13122788edb.9 for ; Mon, 19 Dec 2022 06:40:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kali.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ua8Y8Z4pBPkKAQrNbMtdprGt9Mnzjiq5jD7V9dAC+Y0=; b=G3jXAcTBG6DW2mXzZQy+MnSYx8QarWdNCLBbbNBf4dhSNyVBq7+tEuaA8nyoaQzHSC T2/AIr30A5/xKEqRRe96P6L1Kz8ZiWzCzLOw0JTafXjpX47GhUMZYFYBTmWyndCj6FYi QcyLrVVakhlCJTGDmmXtF61fQr0qclIZ02oGkotXAUi4QmRdWjIjXzedXDc76uwZmtVv 5dobDMpTQsN/K4hVVIZO7KFQjnIqkV8OEpf85/eKN00wxZ4v7c+gRFwKuma8TlvrgAQn xXQIkYf5FFIpu4sCY6SgYscXB2g1shNDKxSaI0FMWEEYAm5iphgy7A0g3hGJT//i2T1S x2Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ua8Y8Z4pBPkKAQrNbMtdprGt9Mnzjiq5jD7V9dAC+Y0=; b=4PXWkRmRK5BFGM3fOUteOG+xpObSstLr54Hmmus6DW/5ednPoY+C30lTVOvZy8JcfL i3DvoWasVzXXEBTbW1wmrdXofvE4f1PF9UuMrHeZYD3M5yeDWB5vz+qTczMXvRWEZ4sq 26u1FsGAGDACygvRWxT19NOmSo3/Pwb6jtWuuAsOs8oEQ4TUhyRuvT/cGSh+0yPSh2u/ IO068/tSAsZs6oAwP406TGCyCPDJSA5cosvGqBCaZguJxKh/LOvojUsz7IkklLMc7GoD KBOn2gh+6vopnaz/oC/jBsNYRydp9AAg6fAwMbOABpFqm0FUjIy9w13CneBuhThcV699 hbLQ== X-Gm-Message-State: ANoB5pnFjyHl+t8NWt90RO1IF2q4+OtQWtKQtM/p8qBFp4MV4+RfMw3E RxcFGXShcHkHdT7qgOCZc6ZMEMhFaqgwTy4ggugssA== X-Received: by 2002:aa7:cd04:0:b0:46b:34c:5574 with SMTP id b4-20020aa7cd04000000b0046b034c5574mr52252953edw.175.1671460814633; Mon, 19 Dec 2022 06:40:14 -0800 (PST) MIME-Version: 1.0 References: <20221219101237.9872-1-johan+linaro@kernel.org> In-Reply-To: <20221219101237.9872-1-johan+linaro@kernel.org> From: Steev Klimaszewski Date: Mon, 19 Dec 2022 08:40:03 -0600 Message-ID: Subject: Re: [PATCH v2] efi: random: fix NULL-deref when refreshing seed To: Johan Hovold Cc: Ard Biesheuvel , "Jason A. Donenfeld" , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Andersson , Andrew Halaney Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 On Mon, Dec 19, 2022 at 4:13 AM Johan Hovold wrote: > > 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, or more generally, whenever > the runtime services have been disabled (e.g. efi=noruntime or with > PREEMPT_RT). > > Fixes: e7b813b32a42 ("efi: random: refresh non-volatile random seed when RNG is initialized") > Reported-by: Steev Klimaszewski > Reported-by: Bjorn Andersson > Tested-by: Andrew Halaney # sc8280xp-lenovo-thinkpad-x13s > Signed-off-by: Johan Hovold > --- > > Changes in v2 > - amend commit message with a comment on this being needed whenever the > runtime services have been disabled > > > 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 31a4090c66b3..09716eebe8ac 100644 > --- a/drivers/firmware/efi/efi.c > +++ b/drivers/firmware/efi/efi.c > @@ -429,7 +429,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 > Andrew already sent one, but also confirming since I reported it, this fixes the issue for me as well. Tested-by: Steev Klimaszewski