Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1007278ybz; Thu, 16 Apr 2020 00:41:12 -0700 (PDT) X-Google-Smtp-Source: APiQypIKd3voXgvyEDB6TBDcpFqht64W+2EKnT1DtknsJNe9HGLJcTAnb11dw9gGljlM56l08XsD X-Received: by 2002:a17:906:18a1:: with SMTP id c1mr8216795ejf.344.1587022872214; Thu, 16 Apr 2020 00:41:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587022872; cv=none; d=google.com; s=arc-20160816; b=P2l1hqFipn2Xp45iEmSINjbGRkq5uqwlKXPKmXlwnsnqqxlkIb56j9MgTWMHB2ZVya 8ZrEgISiw1WX6BgM1njQP+MEv4Nd/vlQwgxbnvkFVUxzUHpG7ponWmeqhNOf0NX3bA7R s2fHJwFn2O2eX6N5C4ICiwBpK+CwGMKU1OXZJJy4ecD8+DR/n0pvfsJf79dZIbyW05MB x49cZ30uWPwjBgJlSGqjF06SRqcEjXUx2IBjucUs3nMZeIC9eZ9gTFKteUfXipvqJZ2o ETiFXqOxigvNm3mIuGfjIdewJn5rWOOypBuA0UIyuTQvwwEj6BDFXLpCFiTg6fRqKY6z NqeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=yc4bs8ffUX06deOApPVVJKWpJfO+fdHaSOfdalggzgE=; b=JT3bDt61K7IwgrnCaJGo3STFRNOpTba2WUKbTB8DWWXefpCzpi2LZHvsoRdzgRd+y3 s8RFgoGORTy0PPnu95YMZFOjULynR/M2U4r7lCfb1Cz/NMwR4ltWw00hV6gFjTuReayl cscETv468dOSr9AIv17t9vUSbnIKgTD7cQ5fu/z0pXbq0Kb+Do3E/eXUPOld7uUf1wJj yXfn1pKF2RobO2qAlTugaZgMYm6XkoR1hlSIYCpwH4ytR/Ga/WuFzP76e1evw6r/ue9x itm9wrbCfRT00LpuJqsOzjwQYGuHGsprkUY4cif78yw+aQBgeT9Nk8tUrqHNxkHr8ct5 Whhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=THez1ktQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a9si11409401edk.466.2020.04.16.00.40.47; Thu, 16 Apr 2020 00:41:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=THez1ktQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439438AbgDPHiy (ORCPT + 99 others); Thu, 16 Apr 2020 03:38:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:40872 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439282AbgDPHiu (ORCPT ); Thu, 16 Apr 2020 03:38:50 -0400 Received: from mail-il1-f181.google.com (mail-il1-f181.google.com [209.85.166.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A38F220732; Thu, 16 Apr 2020 07:38:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587022728; bh=VV/3DC9vERvU4YrbpBLum76SN/pkTOMrb0l8+7m+IYc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=THez1ktQblEbH8mIOjliZ9nHegmEdCiCQOVY75ZyKMIONgngNQ3kLhYCOF/0qE3nL Kr2pWUkvMGr//TIo7flY+1AJ0u6LfKGLOKzRyVczRntnBOzY5OrMCZe7F8rY9K+xSz weDjNA049UXEK24cRxf1QWjTYH+GKtkLwk6TtoBA= Received: by mail-il1-f181.google.com with SMTP id e4so6005785ils.4; Thu, 16 Apr 2020 00:38:48 -0700 (PDT) X-Gm-Message-State: AGi0PuYwXGJyRBc4wwujuOIpq3S8aGaM+p82ne0wsDhAfkMkHMyMX0BV nU6s0Ls8v2dRIDBcEMusVgh8JSvkz2NhYB1iFMg= X-Received: by 2002:a92:c788:: with SMTP id c8mr9210476ilk.279.1587022728075; Thu, 16 Apr 2020 00:38:48 -0700 (PDT) MIME-Version: 1.0 References: <20200415221520.2692512-1-nivedita@alum.mit.edu> <20200415221520.2692512-6-nivedita@alum.mit.edu> In-Reply-To: <20200415221520.2692512-6-nivedita@alum.mit.edu> From: Ard Biesheuvel Date: Thu, 16 Apr 2020 09:38:36 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 5/5] efi/x86: Check for bad relocations To: Arvind Sankar Cc: linux-efi , Linux ARM , X86 ML , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 16 Apr 2020 at 00:15, Arvind Sankar wrote: > > Add relocation checking for x86 as well to catch non-PC-relative > relocations that require runtime processing, since the EFI stub does not > do any runtime relocation processing. > > This will catch, for example, data relocations created by static > initializers of pointers. > > Signed-off-by: Arvind Sankar > --- > drivers/firmware/efi/libstub/Makefile | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile > index 0bb2916eb12b..2aff59812a54 100644 > --- a/drivers/firmware/efi/libstub/Makefile > +++ b/drivers/firmware/efi/libstub/Makefile > @@ -96,6 +96,8 @@ STUBCOPY_RELOC-$(CONFIG_ARM) := R_ARM_ABS > # .bss section here so it's easy to pick out in the linker script. > # > STUBCOPY_FLAGS-$(CONFIG_X86) += --rename-section .bss=.bss.efistub,load,alloc > +STUBCOPY_RELOC-$(CONFIG_X86_32) := 'R_X86_32_(8|16|32)' This should be R_386_xxx > +STUBCOPY_RELOC-$(CONFIG_X86_64) := 'R_X86_64_(8|16|32|32S|64)' > ... and in general, I think we only need the native pointer sized ones, so R_386_32 R_X86_64_64 > $(obj)/%.stub.o: $(obj)/%.o FORCE > $(call if_changed,stubcopy) > @@ -107,16 +109,14 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE > # this time, use objcopy and leave all sections in place. > # > > -cmd_stubrelocs_check-y = /bin/true > - > -cmd_stubrelocs_check-$(CONFIG_EFI_ARMSTUB) = \ > +cmd_stubrelocs_check = \ > $(STRIP) --strip-debug -o $@ $<; \ > - if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); then \ > + if $(OBJDUMP) -r $@ | grep -E $(STUBCOPY_RELOC-y); then \ ... which means we don't need to -E either > echo "$@: absolute symbol references not allowed in the EFI stub" >&2; \ > /bin/false; \ > fi > > quiet_cmd_stubcopy = STUBCPY $@ > cmd_stubcopy = \ > - $(cmd_stubrelocs_check-y); \ > + $(cmd_stubrelocs_check); \ > $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@ > -- > 2.24.1 > Could we fold this into the previous x86 patch, and drop the one that splits off the relocation check from stubcpy?