Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp811402rwb; Mon, 26 Sep 2022 06:14:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7b6tXGPpfB+l2VkDN667+Timk7MvDKWPgaRKZtQb3k97DaMqpzd5UoE/UlpMlYMIWvjYV2 X-Received: by 2002:a05:6402:2949:b0:451:fabf:d88a with SMTP id ed9-20020a056402294900b00451fabfd88amr21963674edb.324.1664198045894; Mon, 26 Sep 2022 06:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664198045; cv=none; d=google.com; s=arc-20160816; b=wgodFARUB2ET3YMJ3qd2a+gEAgGOAoRk0MD1lb7soM1qgY3ERIQSKE8llg75bxo+fJ 4xRRmBT3Jh7hXb0keHrFc66TWCSUQ5n/1PMlAniV0dBlfoxGvAnsqfLkjW5ViBm40c/0 M8bYEoit6lLjgPhfF5A7k+epIh+QkNRA6joAwx4Izl+WvBw5N73b7ZzHx5zZmU/6tEoM FRu7uUOs6SDalRhkeqfQFcKKwndsBz6NTR85+ambhitLMgosWHatRMUvSrbRGlme9d9n iZwtbWb7Z0KC9FRqqsGyLfbKxkve2AqwJHgzv7iVWIbR7dOaUXVnIkeAtGTZAkWMDhR9 gC7g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XxDxWxiI3tNBu2IWkMNgv/OLryiKYKc38OQF/4AzsmI=; b=muQTrRWnWX/2Wu4hmI3KblDOecWtMId4bNMB0+4IeFdRpgQo88FxUp6iwKtKTott5y NZX7mhovnDGyDF/pzSiJaNJSYk8udx0nXiJtopKPGpj85oW1vNcxztORbnboZlY3ob8W 0h3iIRv1T4cz/YMkCjMXESx3Mq1hkAeNNUSsWr4PDYbqV0RDqaf7tO1oPZjuCzaL5ePB 23WLJX7RQPZLnab7BcAOaQk+0vigDJ6gEA/1LAOcfqgt4HYumpCe8sSSsgYtYBpmJs84 2VT3oGKfCllpljBdH0tVv7Y//q9+oLoPi4d3vkfpJIiR90/xLIoayFB9FVRd5OraQSz2 P8iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ufri+XmH; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a056402350800b004539c6d849bsi17045019edd.171.2022.09.26.06.13.40; Mon, 26 Sep 2022 06:14:05 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=ufri+XmH; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235211AbiIZK1T (ORCPT + 99 others); Mon, 26 Sep 2022 06:27:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235657AbiIZKYc (ORCPT ); Mon, 26 Sep 2022 06:24:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 186914D24D; Mon, 26 Sep 2022 03:17:57 -0700 (PDT) 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 8427F60BEF; Mon, 26 Sep 2022 10:17:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DBEDC433C1; Mon, 26 Sep 2022 10:17:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664187469; bh=wuZN+QtA4rf6Hs9xjlQ4uC96UOzN/ztHw+3mXvo/XEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ufri+XmHZKkitq4GBDa6GcYrG33scQr3tNNwjLS95TSE872+Y9SeTTOao93vijS5S GV+JHU3ycUe9MQ6BJs+Vkb/KlmrbI1kPsMrvjcWCO90sXafsw0bTqJvzN5CC4ZcA/X n57juBrGGEdTSI6SKI3uxgrDiCaBcrKVTtBEVgb8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Marth , Ard Biesheuvel , Kees Cook , Sasha Levin Subject: [PATCH 4.19 06/58] efi: libstub: Disable struct randomization Date: Mon, 26 Sep 2022 12:11:25 +0200 Message-Id: <20220926100741.658952661@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100741.430882406@linuxfoundation.org> References: <20220926100741.430882406@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 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 From: Ard Biesheuvel [ Upstream commit 1a3887924a7e6edd331be76da7bf4c1e8eab4b1e ] The EFI stub is a wrapper around the core kernel that makes it look like a EFI compatible PE/COFF application to the EFI firmware. EFI applications run on top of the EFI runtime, which is heavily based on so-called protocols, which are struct types consisting [mostly] of function pointer members that are instantiated and recorded in a protocol database. These structs look like the ideal randomization candidates to the randstruct plugin (as they only carry function pointers), but of course, these protocols are contracts between the firmware that exposes them, and the EFI applications (including our stubbed kernel) that invoke them. This means that struct randomization for EFI protocols is not a great idea, and given that the stub shares very little data with the core kernel that is represented as a randomizable struct, we're better off just disabling it completely here. Cc: # v4.14+ Reported-by: Daniel Marth Tested-by: Daniel Marth Signed-off-by: Ard Biesheuvel Acked-by: Kees Cook Signed-off-by: Sasha Levin --- drivers/firmware/efi/libstub/Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index e0cff3b942ac..7fad5d90898b 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -31,6 +31,13 @@ KBUILD_CFLAGS := $(cflags-y) -DDISABLE_BRANCH_PROFILING \ $(call cc-option,-fno-addrsig) \ -D__DISABLE_EXPORTS +# +# struct randomization only makes sense for Linux internal types, which the EFI +# stub code never touches, so let's turn off struct randomization for the stub +# altogether +# +KBUILD_CFLAGS := $(filter-out $(RANDSTRUCT_CFLAGS), $(KBUILD_CFLAGS)) + # remove SCS flags from all objects in this directory KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS)) -- 2.35.1