Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp666418rwb; Mon, 26 Sep 2022 04:27:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4aj/KR7Ny0Myb7hNCQE3w+4XaoHMyWlqe/+mJiAOoV+NfIeJT2TiC7L8sgFZK9E/kq2bZc X-Received: by 2002:a05:6402:5246:b0:452:76a7:934d with SMTP id t6-20020a056402524600b0045276a7934dmr22562059edd.137.1664191674194; Mon, 26 Sep 2022 04:27:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664191674; cv=none; d=google.com; s=arc-20160816; b=C5EJHm9VGvom3d2DqVvAfGqeRdEIKmBoZi0cC+g+9RxTfua2IsjRrlOhTpUP5wlXYl d0lIlvA9ZwfFmApOVPilWsaLWgUkpff1sFa+bi2Fv4kVIoNg3rcigpUpgUefRQFm3V/Z 6/UdjJFNpBED4i3UVauHQxb1m8ZlcM3VzM8DehabX0yeCCNB2UlZ+Y5H1ut95adbz7jZ ri2ImrQMow6/pYdwSjrlIbif1WoT6WAaIB4MfvogbOj+l+UcTAa/SwrkQGMG53+5opJX afSt4dIRAmEW7KxjV10tDSkXuymjio4m7RBVVUBa+SnB5UoFT3CVuis9itBqhRStqFC2 xAiQ== 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=rmYgexcBWx5sLUtXscXo7co9y0u+bmMnRpbC+PT/Ql8=; b=Vn8rboZPO/LCW2afJR/Be+A7E1y9k3K2MAAt/JbIUN1R6fhxfRQlGlk8MfMNNxT6/G quWdzHnCWlOc9HgZvMoqOqT11R7+9f4tiw4xOjdUFv64yiF2OVdsrxctFwfkbjBdrZj4 V4xG3wKxrlLCFmk64nFcdEgPPlod17KnSaAiapp2BIeGyns4mzJCnJYOs8UuivOhLGNX NRvhPO2Xzievv1Pnkx6V9jaNWIu7Bn+Cipn1c360VwE39BKOpBSPa1evdWn/nEzyWCCH 5GgoukPyvI206xFXleM3AjK2x4OLKlUwUdPc2q6coTMmzRHGWqqQYfSBpOuphjUuYnNm KZzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T++VU+94; 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 jg11-20020a170907970b00b0077c3f58a063si16640343ejc.3.2022.09.26.04.27.28; Mon, 26 Sep 2022 04:27:54 -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=T++VU+94; 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 S235321AbiIZKW4 (ORCPT + 99 others); Mon, 26 Sep 2022 06:22:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235267AbiIZKVq (ORCPT ); Mon, 26 Sep 2022 06:21:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 729444BA77; Mon, 26 Sep 2022 03:16:16 -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 ams.source.kernel.org (Postfix) with ESMTPS id B1A6EB8091F; Mon, 26 Sep 2022 10:16:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01DECC433B5; Mon, 26 Sep 2022 10:16:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664187373; bh=DK0NbqhTLaRyNgwtyno+uqowQ7PXnYBl5cPbBiu6Q+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T++VU+94/NENPhnsENQAI9mJLPF+EIV9sCrKLGP/cVpbLhzJZL4olWHT7LvJMbsPz Rg/rEUrTB8ENBPsF8XfZ05EOklGQTqNWxRX6EMOXRjgU07V58FqYr9c2YNS1/r8HY9 kzGEsCtWQjfqVf4Ae7h8vbS2U5rLqNRbx+ZsU6GI= 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.14 06/40] efi: libstub: Disable struct randomization Date: Mon, 26 Sep 2022 12:11:34 +0200 Message-Id: <20220926100738.463310701@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100738.148626940@linuxfoundation.org> References: <20220926100738.148626940@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 54dbcec7e06f..7dc2d093962e 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -23,6 +23,13 @@ KBUILD_CFLAGS := $(cflags-y) -DDISABLE_BRANCH_PROFILING \ $(call cc-option,-ffreestanding) \ $(call cc-option,-fno-stack-protector) +# +# 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