Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1361723ybz; Thu, 16 Apr 2020 07:53:24 -0700 (PDT) X-Google-Smtp-Source: APiQypILof8V0CrMPWs3raeAn/cx0tD67GpCbfQ6Wcq6goEY4Cu7dGVzt/LI2Ucy+mF7KSKBLDUg X-Received: by 2002:a17:906:d215:: with SMTP id w21mr10005715ejz.132.1587048804646; Thu, 16 Apr 2020 07:53:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587048804; cv=none; d=google.com; s=arc-20160816; b=TG9igwQIGjZxb/dVI6FYd5l5ieIsrxvnx7JmQ0YjpEUOkdmg2YR3g9Bd7ri5chd+Yp hu+rlrMwymz9gzTLD6MYDMi67IWSOZPei1rKide1Gp1o4YjB0YI4SlZPaN043TmXZ6ZO G04Zz8Wq7/ZK/PSFbjQOxFIm+RofZWeoC4clw9NOKJ9NVPzfr3iv07cxJmLz0/l5sKvX VPfsE32rxW0Vcv/l3EktRZLLzoIDA5F7smYGBuLg5+Cd4jmT4WKKtB+Td6TIz0OPrL3W ClcABKk8abtO8XomYhicFq8r6e2mrF0cCihFr43mK+MvH2NQifwvrWka89ALJpP4ZG0R gfFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:date:from :dkim-signature; bh=hqU3RukC+Wcy1beI5mHwFrne2ji8Zyuh2QqLhWnxtHQ=; b=ufkTj1CNck3Ty4VsnYsO0MfhKHg7BH8+Un/4grD7z5NEhYCDt0MxVFliRlFhf9kWRI wWFHkgHEwXUjIOy6oL9/w3T0cvkg6YEfe3OMt1xwfCFcUoe/NLdZX3HCuyLBUexodPTX OYRxLScPtafmzzBLZ/gVjKEdXiksZ1e8RwgwW+7sBTdR2vja8JmEqrFozMlb63O9mJ5g eNS8DWFy285kZh5p7JVRc8+lGfNjQv3QA0VoDN/loE1SLxGD0Ve6WFEBezePzDYp4Ysr 3wcF/nXBvV8m7iWqLI3WZS9p2KUfk+guRWAOXtWRuFnup2RNcf3JqumlpJPpBh9DgqGM bceQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=fTo8Ucms; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 7si11846827edv.167.2020.04.16.07.52.50; Thu, 16 Apr 2020 07:53:24 -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=fail header.i=@gmail.com header.s=20161025 header.b=fTo8Ucms; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394736AbgDPOsi (ORCPT + 99 others); Thu, 16 Apr 2020 10:48:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2394595AbgDPOsS (ORCPT ); Thu, 16 Apr 2020 10:48:18 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5409BC061A0C; Thu, 16 Apr 2020 07:48:18 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id o10so16537703qtr.6; Thu, 16 Apr 2020 07:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=hqU3RukC+Wcy1beI5mHwFrne2ji8Zyuh2QqLhWnxtHQ=; b=fTo8UcmsXD7A4NEtK3NfBs49RNNLGi8bxg8SWycx2D/czAgWIQTTGo/VvyAmQ+0fYs kx+EfbJ7RyO56KbIZfrC5aCoJdh6TyLnlrfjp0NCPwAw6S57AU11ThPuH9nJQCdmG3H5 dno7C3cer5UF4qIRAtg6tbFzFUPOZW7qfQntg6Cfe8S44N+OOUjhpylckOpPTPsxmKlX jiFwa3EbZgVlr/ngN8+zDaANiyc3pwcm5y4QmI055bj8g5IB7mHGaE7B09V3keALJFfJ 7pUq8YICJvXL4P4/T4M2D19LkyOmkaPtzLHVqgwuqOB3dNezlTF8uWqEf/cJy+97EaNa xG9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=hqU3RukC+Wcy1beI5mHwFrne2ji8Zyuh2QqLhWnxtHQ=; b=MrWrKXKIj0jt2d83c9a7t8vMOBCjbUnDzk3VnrGXzaGlbI5+ZAi7lVr5zRvSlqQXZk /V6LswMkUjbWaRxk82wyQv2AwvgcZF8XZMd5lc3eTDjTVSbHe11ji9UgbLzYpsiOh4Ma o73aWBKuLJZm1x37V2Jz087ZwtxJMdABEhy5nnneGexdlXsufKz1BkpSmvHlTiYTnx9l 96hWlTGUSBQNyEtWifRBl5MKB5PyDbRn33YvPk9hvjj1/gu3+RFlbyx8WmEM+AaZ7ZnQ bqGAt4tIvKMVxvOpzCsf9mjtQOP6LY6B+yDFD5QsilRyq/YOgMZnifb4wYG0dM28Jes+ GWNw== X-Gm-Message-State: AGi0PuZhqkMBoHLujRx4R3rOAs34zbzzymbwyVt5mqd4k1KLHbWhoZav pgIb0ahtKcyVWAP0xwa8T0g= X-Received: by 2002:aed:3bf2:: with SMTP id s47mr15097558qte.126.1587048497317; Thu, 16 Apr 2020 07:48:17 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id o7sm2584717qkh.76.2020.04.16.07.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Apr 2020 07:48:16 -0700 (PDT) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Thu, 16 Apr 2020 10:48:15 -0400 To: Ard Biesheuvel Cc: Arvind Sankar , linux-efi , Linux ARM , X86 ML , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Linux Kernel Mailing List Subject: Re: [PATCH 5/5] efi/x86: Check for bad relocations Message-ID: <20200416144815.GA3267283@rani.riverdale.lan> References: <20200415221520.2692512-1-nivedita@alum.mit.edu> <20200415221520.2692512-6-nivedita@alum.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 16, 2020 at 09:38:36AM +0200, Ard Biesheuvel wrote: > 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 Oops. I tested 64-bit but not 32-bit. I'll fix. > > > +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 Ok. > > > $(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? Will do.