Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp644756ybl; Thu, 12 Dec 2019 02:34:07 -0800 (PST) X-Google-Smtp-Source: APXvYqzZH78cEtdnoJuYXrfb5kZN458Re4H+dO8dSSLUkvzTgWde4ndhQ7pofMNQWfBkWterqzD2 X-Received: by 2002:a05:6830:1097:: with SMTP id y23mr7227681oto.332.1576146847013; Thu, 12 Dec 2019 02:34:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576146847; cv=none; d=google.com; s=arc-20160816; b=wJWFMtlJEtST0EGiG4qBXUg7oUkPaAR0RNJ69XkbfhxudvhInZFhTqiasVse8cWY/T RH3Gzc1gK0t8s5b+2zRiFiRE58MklHQQucnAkd9gTmlK2OJQeXI5IaL1lG2uVzHtH5Yy /3wn+rEjeuna7Sl9VoDAfuW7YhX7yT8E+KJB6HyWTka8DsY38OocTYE3Q0DQhJ4dqdHI DVENa/souTU+OvjFRomsNZlUm3uBx58WuJq6GXE88iyMKIWiU0Ohl8mfUoGc+0JBuKud pHgrnLuLF5+iFEn0dR6XjbdppQGE6oamVhs8vjkcDy6rIpYNtXTZfFG8PliyQ/VvVxmL zBvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Xhb4ZJoupfFMXp/pCal+74SHCUI6sDdlcj1jTQYldEk=; b=bYUSoV8RF39U6hV6FZGSo+5WHmV8c30h5zpBIA9js+xa9zdCtyqFZ1QDwzAVUk3nZT K3dZmVNZta7+5QqpFgYd26lz8k/3t4VhNpTHJn9NwFzY3Uy7JaltxGsJgOgWkAC1qn86 12zgij2aus2Y4tpqe/yZKykgMmcA/hhdwNE+GhB53Lup3E0NAWE/g4RE9aSWTy6F0hoT HO0X5H1BmSOqxXyBl/fEpX0ks+ouSCEl7+i8c30f5f7xEr+OXyXY+xxVn0QyIhPBHMI7 EI6KrDX5ktZdPIVtQtdnuw2JU3u28hPrHhN/S2E60mrLtu+ITFaNBPESgZhWfgrha5nq rnBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z5CLFHny; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11si2729576otk.290.2019.12.12.02.33.54; Thu, 12 Dec 2019 02:34:07 -0800 (PST) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z5CLFHny; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728716AbfLLKcP (ORCPT + 99 others); Thu, 12 Dec 2019 05:32:15 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:31942 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728696AbfLLKcJ (ORCPT ); Thu, 12 Dec 2019 05:32:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576146728; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xhb4ZJoupfFMXp/pCal+74SHCUI6sDdlcj1jTQYldEk=; b=Z5CLFHnyyiohcmatFFTANBfKg1SPx/mtQCOYp+0R0IfWaCLze8sVWEtvTeVa29aWCix38g dUF8HqdKTLjC0ae3cIgIlqJ3rgG+Tkb0aepNhs78MGZuQ7RqII9aOeMEbSQ8RZgFG8fTAi nhXROhJNvHn9Kc3VdKJLI6IDFhOVFRs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-119-DFewpmFsP2aPnGtP2VJ2eQ-1; Thu, 12 Dec 2019 05:32:05 -0500 X-MC-Unique: DFewpmFsP2aPnGtP2VJ2eQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0E98D8017DF; Thu, 12 Dec 2019 10:32:04 +0000 (UTC) Received: from shalem.localdomain.com (unknown [10.36.118.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 995D663BCD; Thu, 12 Dec 2019 10:32:02 +0000 (UTC) From: Hans de Goede To: Ard Biesheuvel , Thomas Gleixner Cc: Hans de Goede , Dominik Brodowski , x86@kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5.5 regression fix 1/2] efi/libstub/random: Initialize pointer variables to zero for mixed mode Date: Thu, 12 Dec 2019 11:31:57 +0100 Message-Id: <20191212103158.4958-2-hdegoede@redhat.com> In-Reply-To: <20191212103158.4958-1-hdegoede@redhat.com> References: <20191212103158.4958-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 0d95981438c3 ("x86: efi/random: Invoke EFI_RNG_PROTOCOL to seed th= e UEFI RNG table"), causes the drivers/efi/libstub/random.c code to get use= d on x86 for the first time. But this code was not written with EFI mixed mode in mind (running a 64 bit kernel on 32 bit EFI firmware), this causes the kernel to crash durin= g early boot when running in mixed mode. The problem is that in mixed mode pointers are 64 bit, but when running o= n a 32 bit firmware, EFI calls which return a pointer value by reference on= ly fill the lower 32 bits of the passed pointer, leaving the upper 32 bits uninitialized which leads to crashes. This commit fixes this by initializing pointers which are passed by reference to EFI calls to NULL before passing them, so that the upper 32 bits are initialized to 0. Fixes: 0d95981438c3 ("x86: efi/random: Invoke EFI_RNG_PROTOCOL to seed th= e UEFI RNG table") Signed-off-by: Hans de Goede --- drivers/firmware/efi/libstub/random.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/efi/libstub/random.c b/drivers/firmware/efi= /libstub/random.c index 35edd7cfb6a1..97378cf96a2e 100644 --- a/drivers/firmware/efi/libstub/random.c +++ b/drivers/firmware/efi/libstub/random.c @@ -33,7 +33,7 @@ efi_status_t efi_get_random_bytes(efi_system_table_t *s= ys_table_arg, { efi_guid_t rng_proto =3D EFI_RNG_PROTOCOL_GUID; efi_status_t status; - struct efi_rng_protocol *rng; + struct efi_rng_protocol *rng =3D NULL; =20 status =3D efi_call_early(locate_protocol, &rng_proto, NULL, (void **)&rng); @@ -162,8 +162,8 @@ efi_status_t efi_random_get_seed(efi_system_table_t *= sys_table_arg) efi_guid_t rng_proto =3D EFI_RNG_PROTOCOL_GUID; efi_guid_t rng_algo_raw =3D EFI_RNG_ALGORITHM_RAW; efi_guid_t rng_table_guid =3D LINUX_EFI_RANDOM_SEED_TABLE_GUID; - struct efi_rng_protocol *rng; - struct linux_efi_random_seed *seed; + struct efi_rng_protocol *rng =3D NULL; + struct linux_efi_random_seed *seed =3D NULL; efi_status_t status; =20 status =3D efi_call_early(locate_protocol, &rng_proto, NULL, --=20 2.23.0