Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2971518ybt; Mon, 29 Jun 2020 11:48:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHiWZbU2aQSZfQg/1TmFajstW5wy3lGx+2/Ddv1tVP7fwaCNVUESduVZM8xPLCf3XvYDL7 X-Received: by 2002:a17:906:cd18:: with SMTP id oz24mr14685501ejb.118.1593456495379; Mon, 29 Jun 2020 11:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593456495; cv=none; d=google.com; s=arc-20160816; b=bQVu+hCGiBe1aq/bMn8NGIRKlh/xXPOWWaTIBSUIaqSnNOHd0ZKji930pZtSok9igX hbu7AA1pFf3x0GCkffzjfYWO9jaENlIV6gZ9mwYwcca+cha+tn3r6Zf+UX541SfpZK4/ 0AKq1drWSLbD+sEe/JSXoq38dbPBd0EIT6D5L1VkLnYaXrAbYnPgJBS1/nHHepdUqaSM bi3/gHsLvhKVECKfMElCb7hj89Oj55jryN6HIehtMynBMfWQJN7qe7b+gprsGosxPetX 8M0Eh8YXKhTd0xdKvrOs2G1ZwNMLjHnMMy+t4RH8oMfc9QXUoFT6isKSQV4AplJ0DP8Q WNog== 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:from:date :dkim-signature; bh=bmVfJADPu1Rf4BNpweJIobmBh11XdYvG31saYbh8f2A=; b=Aq6P1ap7vKYwVBBEC2/6i4WTcxMZ/mUxr+DX2fENIBSHmaD5cvzMx4eKAWDkpFiuuz 4dDQfc+gBf7Lz42SC1qpcI4oPHQ9E4vXTRl5KfSWLGrWeHE01Sj17DxNFXX3rE5icF+p vOqjH9Mryn/inD5+M4qDl8dZtxdnA3JWbNPzV0ZR5F/5TIhi9KyAIXkaozCOPu4Qd5pC dCPEDKvlH+GmN+iP14+qUCghIRpxG8uY10xX5ybGJswgo4KbQ6iWiLBXHO877MaE0rUb L7uwoofj4uP1RI1vVWaZvD3mGSNEiRDBN8cj2t0jqdcZnT6ROvm1294+D0yvpGiqDugH zLZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hSk0c1AM; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c3si216788edn.385.2020.06.29.11.47.52; Mon, 29 Jun 2020 11:48:15 -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=@chromium.org header.s=google header.b=hSk0c1AM; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729357AbgF2Srq (ORCPT + 99 others); Mon, 29 Jun 2020 14:47:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728003AbgF2Srm (ORCPT ); Mon, 29 Jun 2020 14:47:42 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84AB6C030F10 for ; Mon, 29 Jun 2020 09:20:33 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id bj10so2056975plb.11 for ; Mon, 29 Jun 2020 09:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=bmVfJADPu1Rf4BNpweJIobmBh11XdYvG31saYbh8f2A=; b=hSk0c1AMBltSrv0MFlxEGcT9a7odSjKO2OJZOsVk7IVAdXiahqsmRRyTe2RDOpfyoD eLWi3Gayo01bsT5h8X0z083tmA258K5YNdwWx5e774rxk5zFYwaRA4kJHRdEdpWKW2x4 bhw9e5UVXTBAKIauThvNjKld6jnT21xxDT3Gs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bmVfJADPu1Rf4BNpweJIobmBh11XdYvG31saYbh8f2A=; b=PweYMWkFfVrtORlNwQZkG4Hsi5BwysZGURJNnVGYxF2ey+zhm1HqXE/d0+cjKjmmvi L9wuVjfNa4eACmVnSObmTi48V6xB32Qjoivt5VJCzoiP5QV+PacFnO8JDHcIsayoMsvb nij75FKLIGTlBIbjOasp+t4uI8NRH1DXyCOo2xoTL2D9K51Sr69WWLIjE1M968wjLyBr mUxJyRFNmZQJjI+mHkm4lKbM7x2UlnM/hDWIcaR4SJnIb8Kswp1WclTE4D+EJre1y7K8 AM9auolNxKv8E9w4DWb4x00oHouyfv8WZTDVyfRpx+uBf3/z7zaxobzHv6mV9DKSEjv2 +53A== X-Gm-Message-State: AOAM531A6dZ1KOwk8mjmYgrIAGNAA9++gVYEv1y+xC2ekzvasQFR3FUK Lw1M1qN7EW1OgFNWoCLYoxu/5Q== X-Received: by 2002:a17:90a:9292:: with SMTP id n18mr17806395pjo.112.1593447632977; Mon, 29 Jun 2020 09:20:32 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id m2sm183486pfb.164.2020.06.29.09.20.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 09:20:32 -0700 (PDT) Date: Mon, 29 Jun 2020 09:20:31 -0700 From: Kees Cook To: Ard Biesheuvel Cc: Arvind Sankar , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , X86 ML , Nick Desaulniers , Fangrui Song , Dmitry Golovin , clang-built-linux , Masahiro Yamada , Daniel Kiper , Sedat Dilek , Nathan Chancellor , Arnd Bergmann , "H . J . Lu" , Linux Kernel Mailing List Subject: Re: [PATCH v3 7/7] x86/boot: Check that there are no runtime relocations Message-ID: <202006290919.93C759C62@keescook> References: <20200629140928.858507-1-nivedita@alum.mit.edu> <20200629140928.858507-8-nivedita@alum.mit.edu> <202006290907.E5EF18A@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 Mon, Jun 29, 2020 at 06:11:59PM +0200, Ard Biesheuvel wrote: > On Mon, 29 Jun 2020 at 18:09, Kees Cook wrote: > > > > On Mon, Jun 29, 2020 at 10:09:28AM -0400, Arvind Sankar wrote: > > > Add a linker script check that there are no runtime relocations, and > > > remove the old one that tries to check via looking for specially-named > > > sections in the object files. > > > > > > Drop the tests for -fPIE compiler option and -pie linker option, as they > > > are available in all supported gcc and binutils versions (as well as > > > clang and lld). > > > > > > Signed-off-by: Arvind Sankar > > > Reviewed-by: Ard Biesheuvel > > > Reviewed-by: Fangrui Song > > > --- > > > arch/x86/boot/compressed/Makefile | 28 +++----------------------- > > > arch/x86/boot/compressed/vmlinux.lds.S | 8 ++++++++ > > > 2 files changed, 11 insertions(+), 25 deletions(-) > > > > Reviewed-by: Kees Cook > > > > question below ... > > > > > diff --git a/arch/x86/boot/compressed/vmlinux.lds.S b/arch/x86/boot/compressed/vmlinux.lds.S > > > index a4a4a59a2628..a78510046eec 100644 > > > --- a/arch/x86/boot/compressed/vmlinux.lds.S > > > +++ b/arch/x86/boot/compressed/vmlinux.lds.S > > > @@ -42,6 +42,12 @@ SECTIONS > > > *(.rodata.*) > > > _erodata = . ; > > > } > > > + .rel.dyn : { > > > + *(.rel.*) > > > + } > > > + .rela.dyn : { > > > + *(.rela.*) > > > + } > > > .got : { > > > *(.got) > > > } > > > > Should these be marked (INFO) as well? > > > > Given that sections marked as (INFO) will still be emitted into the > ELF image, it does not really make a difference to do this for zero > sized sections. Oh, I misunderstood -- I though they were _not_ emitted; I see now what you said was not allocated. So, disk space used for the .got.plt case, but not memory space used. Sorry for the confusion! -Kees > > > > @@ -85,3 +91,5 @@ ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0x18, "Unexpected GOT/PLT en > > > #else > > > ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0xc, "Unexpected GOT/PLT entries detected!") > > > #endif > > > + > > > +ASSERT(SIZEOF(.rel.dyn) == 0 && SIZEOF(.rela.dyn) == 0, "Unexpected runtime relocations detected!") > > > > I think I should be doing this same ASSERT style for other explicit > > DISCARDS in my orphan series so we'll notice if they change, instead > > of being silently dropped if they grow. > > -- Kees Cook