Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6826234rwn; Tue, 13 Sep 2022 09:29:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5I4b+KOH6pMFV0i/TG8Qdslj3pTngoAdX15AAthQLG++ezjma0SE0CLv0k4hZkaXzbHXMn X-Received: by 2002:a17:90b:4d81:b0:202:d535:d324 with SMTP id oj1-20020a17090b4d8100b00202d535d324mr87268pjb.133.1663086544677; Tue, 13 Sep 2022 09:29:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663086544; cv=none; d=google.com; s=arc-20160816; b=DN85f/crxxQhELA/yk84muYFLhtD+XY7R2q1YH02GMjStPcAcT6OxyvFd6LUq8W21h RJZ1QpAVyiU/MCFlf9AC5VzJ6m9eU5lzJMlQJZUKpx5sKFYuc5QsVQljMyQfvXAyGTCA B9Qm9T2A3/y/8XpdYBdZL03eJRcbdJcHijmIZOu+Z9tCw1tPS1T97utT0PbGrOAEDrta 23cXqCbyuUeUrwkIwDmg+akuk5efk7sOSBxzpY+vIYkbC9GqmiACFmZyzNBPcOV2t0fm ypXYU49xO0E96ceMQKVStBiFmMZvJivrWRcVY+JiZl1O3eRF/mSnxJ/lQi7Od7BhM8ut qMEg== 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=ZFeotvF3cZELPApbGPS0KP+AY5bnHStWhNQiDI31vXI=; b=lEHUyU9DUhFtf4Qn0rCXd0PlF6xswFbU+Y+s/DRmDBRlP4F6Q/HM2N/J6GqE1xiRcF ArP4AGb0PwlaxAZoRTybYI8KDWOJA+n0RP57Th/jVYXyb0ArRCgBnVEF9sUxCU3uZ15X HMl+pQz5WoKm9ps+PpM9k0EZ5dW6DokOZBM7axbqPaQDIfTeYZq5ma2fIvVXEDuWHen0 oeOGXhPY89Vr3WUfwTXOOSQK2RYoNHgMZxkACXaOY+Un3zKA3jCvkdh6Eb8h17Ejyr7k 3+cV+m2G9CyydtpU/OqwPUjnuZjV4Cv1wNrc1eGHjQ6rYd4zikKtBuUJIRdgiYhbY6B4 QS5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="XxhBr/II"; 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 n16-20020a170903111000b0016ece04936dsi13725540plh.504.2022.09.13.09.28.51; Tue, 13 Sep 2022 09:29:04 -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="XxhBr/II"; 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 S233879AbiIMObR (ORCPT + 99 others); Tue, 13 Sep 2022 10:31:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234002AbiIMO25 (ORCPT ); Tue, 13 Sep 2022 10:28:57 -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 097A2D117; Tue, 13 Sep 2022 07:18:12 -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 85A4C614C2; Tue, 13 Sep 2022 14:16:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91C6AC433C1; Tue, 13 Sep 2022 14:16:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663078597; bh=0DGqUM5pxCHewn584S/WfwD7sPV8shohKdVeMsl6Ipc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XxhBr/IIZ/1YFy9JJQfybVvvdXMmViTzshdEDa4v2Z0FqnmKQ/ILhMGIFVeWBHJfV RLRAIzrTyf2XDjEp28I5yzdS82GC7NdBTMyp6pj75ht2y6I6IIoXpOz59FQNcV0DyA RnsSI3p9rCp53oBSVxwILKxrFi0q2khE9SAPhfu8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Marth , Ard Biesheuvel , Kees Cook Subject: [PATCH 5.15 002/121] efi: libstub: Disable struct randomization Date: Tue, 13 Sep 2022 16:03:13 +0200 Message-Id: <20220913140357.429444190@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140357.323297659@linuxfoundation.org> References: <20220913140357.323297659@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.1 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,T_SCC_BODY_TEXT_LINE 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 commit 1a3887924a7e6edd331be76da7bf4c1e8eab4b1e upstream. 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: Greg Kroah-Hartman --- drivers/firmware/efi/libstub/Makefile | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -37,6 +37,13 @@ KBUILD_CFLAGS := $(cflags-y) -Os -DDIS $(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)) # disable LTO