From patchwork Wed Jan 18 01:02:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khazhismel Kumykov X-Patchwork-Id: 44902 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2074362wrn; Tue, 17 Jan 2023 17:11:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXsfWRhhLp/nEfAfRa78/hTtHUaMzM4WbRFnclSC7Na15eD18OqWfptjCb0PSGi6imgaorU2 X-Received: by 2002:a17:906:4b4c:b0:871:e336:cd2a with SMTP id j12-20020a1709064b4c00b00871e336cd2amr4912065ejv.47.1674004263175; Tue, 17 Jan 2023 17:11:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674004263; cv=none; d=google.com; s=arc-20160816; b=dM98YXjIHachoRg7+ZLEzB4/6lUt9UssF+U9lG+DdH0hHr5efRgbOY2X5Jt5sVKm8C 3PaNb9PwkvhlFBvhbP6jThlIYk7K7ZViC0KrDnkNcWV0KZuh9e8JSiEtW41Ba++TmXWy 1lr7ADJbp1kPnU3iTAioP2pl/d6OGCnyZihiKLd+3EQEx5pjriNDFaN3cYUtevAANKAb OUxmWEp31NtIzaOLG7ZKS6Itxp/HtPPY04KpoLX+GdPGjwj91jwgcZhQiNzeYYUrtU2m nii+qnDCkoFKXP1PGYXQlijQuGLt7+sKAzqIyzmDb3ve22TBv2Mvg+WbXXttxdVWpCDB OWRA== 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=7/mtfAEiznKTs6LljSjzgO8ce+jXldLwxAog2qB3K6U=; b=ixXXlbpzROIV7Js4hIa9W85YKao71/CEYpDYAolQYuwMJ6fEYRZj5b39m1G2Wsyeo0 ZGwNLcPto3w2EAc/8gpOwJKv4fuybBhCrSW48V7YS62eqWz3046jDiJrFsp1zjvFaYFm wH3C2tey/SO64TFftgNKv8wAMSNJWM3Gzxm/F+RweoUCykzWXi9RMNbQciQ7RpzC21KF WRTjO3H6N49McsxBKnal3n/ZA1/XfiaYhFgJiMUa92Mle4ET9nEwDi6/L9MHHRp11N+W uDhF/cv55hZ5MhgQdwBb+2UMEAKT13alV9f2RWCRBuI7YU1jE9fMNIe3BTuDpZzk4VVT h9mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TLkv8I36; 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=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rh16-20020a17090720f000b00877571a4f49si461767ejb.794.2023.01.17.17.10.39; Tue, 17 Jan 2023 17:11:03 -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=@chromium.org header.s=google header.b=TLkv8I36; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229996AbjARBI7 (ORCPT + 99 others); Tue, 17 Jan 2023 20:08:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229825AbjARBIK (ORCPT ); Tue, 17 Jan 2023 20:08:10 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96481193F9 for ; Tue, 17 Jan 2023 17:02:53 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id 7-20020a17090a098700b002298931e366so642417pjo.2 for ; Tue, 17 Jan 2023 17:02:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=7/mtfAEiznKTs6LljSjzgO8ce+jXldLwxAog2qB3K6U=; b=TLkv8I36T8svQHzBurky16JF9NaohSi44H3po39FOfSOhftznrWgK2/wMmZ5V3Zp+w Is3AexGXfjwZoha/7x6LUbsLbqOcSIEInugOIu28rvnoOAAy6BXDh23d8MQgAgiNMe3s oxVyjVTMkZfyv/1qQD1peJ8Xn02/7pgzvSxuI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7/mtfAEiznKTs6LljSjzgO8ce+jXldLwxAog2qB3K6U=; b=63zva3lH0knlpI3wGGyuP3fo009xgBi1YZl3h12xSx+6mI80fWpAiTHIxUXokU9gN/ Wqo2Eti0qsfVt7aSxqANmbH6GF+LIzbq6ScyI0/V0U4PjfroMplo6lKu/CO48yF25YtH 6nZi+KOWzPnFIiIYAZzJimy6m68083Xcl9WqnqpToMe6sSBh/e6YEAE1ojDxqU1atJte yMAJArYNmWVk1aeyV9XvpdR91RYV7o+u7mJh1FcXtLu1y+FjHWlraIvIi01ApF5/1GEM VP4LPrjp+E92HvHOQNhJI2hoOGAdX1rN2CezlPsPye1SQRsvYMjJi0jbLTqriM0B0IqI BKNg== X-Gm-Message-State: AFqh2kpjJr4nydYmCFxUaQ/+XwQ78hSlbfOlUttzWTM7QmVkO2mn0WFy X944VJsfPHHf4BAVPmtbifEUWw/OwFSzkYGO X-Received: by 2002:a17:902:a614:b0:192:8ca0:b86e with SMTP id u20-20020a170902a61400b001928ca0b86emr4457621plq.35.1674003773175; Tue, 17 Jan 2023 17:02:53 -0800 (PST) Received: from khazhy-linux.svl.corp.google.com ([2620:15c:2d4:203:ab54:d6ee:36f5:912d]) by smtp.gmail.com with ESMTPSA id x24-20020a1709027c1800b00192588bcce7sm126133pll.125.2023.01.17.17.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 17:02:52 -0800 (PST) From: Khazhismel Kumykov X-Google-Original-From: Khazhismel Kumykov To: Greg Kroah-Hartman Cc: Sasha Levin , linux-kernel@vger.kernel.org, Evan Green , Khazhismel Kumykov Subject: [PATCH] gsmi: fix null-deref in gsmi_get_variable Date: Tue, 17 Jan 2023 17:02:12 -0800 Message-Id: <20230118010212.1268474-1-khazhy@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755320694209405849?= X-GMAIL-MSGID: =?utf-8?q?1755320694209405849?= We can get EFI variables without fetching the attribute, so we must allow for that in gsmi. commit 859748255b43 ("efi: pstore: Omit efivars caching EFI varstore access layer") added a new get_variable call with attr=NULL, which triggers panic in gsmi. Fixes: 74c5b31c6618 ("driver: Google EFI SMI") Signed-off-by: Khazhismel Kumykov --- drivers/firmware/google/gsmi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c index 4e2575dfeb90..871bedf533a8 100644 --- a/drivers/firmware/google/gsmi.c +++ b/drivers/firmware/google/gsmi.c @@ -361,9 +361,10 @@ static efi_status_t gsmi_get_variable(efi_char16_t *name, memcpy(data, gsmi_dev.data_buf->start, *data_size); /* All variables are have the following attributes */ - *attr = EFI_VARIABLE_NON_VOLATILE | - EFI_VARIABLE_BOOTSERVICE_ACCESS | - EFI_VARIABLE_RUNTIME_ACCESS; + if (attr) + *attr = EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS; } spin_unlock_irqrestore(&gsmi_dev.lock, flags);