Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1405209ybv; Thu, 6 Feb 2020 03:31:41 -0800 (PST) X-Google-Smtp-Source: APXvYqz7MkLvTX1H8qmcAu9oz9915dIgpfLpTzpVeYAzSOwGrPq0xisdZN8R3qe5on8/GmdFL10t X-Received: by 2002:aca:f1c2:: with SMTP id p185mr6672762oih.87.1580988701261; Thu, 06 Feb 2020 03:31:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580988701; cv=none; d=google.com; s=arc-20160816; b=h8rirO6TshcLdH6YYirnwEh9ElhqDVUunShShpYZQpMoli+N/QhMxcosqUgY/ibydZ aCK2vUyBaKrESAGhLVYbacyWDWS/G87BOfBiruEmg4aZ5ttdRmpH1AV+rPUp10IrRDcW O12w2ZG5/W5Oolx3O4TTNTO8o7EACxipE1iNMoVyHefvVyonWJkVehlROd+5lWQ0BWPW PY3M7mpEJ3x1FMBz3gAdBeCLK8nGFuG4n4XgwgovJ0aRKf6eLq24ZEH3F2MWAxzguix/ zmoeY8/1Zf70sOiiCtyrh1RZb+7LHaB1M4yFumR343T0WPuIz40Qi+1jIO7vOPnZlGWp aLxA== 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=dYQuztr5x7HOTEbo7y727kXqDcOFz4Xay/pJ3yDZkOc=; b=s9VlY/HmaCFtUerXJDoVjFeg0kgBSe+sG4RaptEk44tCimguXngU4ldBaq21sT+5h8 /ADzHUZ6dxPpol3Fp2FjyNKjGMgGY+Y4/K94uD/cZS8OV1uc1zmvD554kbn+9zWmYM3h zOjeeFpScHAx9CiGDFzVXXggVC7DgL7VPxoRMs9A8+OsLoew6AAOJBX8NJMB27PdyShl M3/zDFiHD6slkJunGILxB0GAKUbewDGttCGeMyKsFvveGIi3U0bSrHhcJcJBEM7gGZcU kO8wGYyKbe4qSAJFKj1ZaovkVu5Xh9m+aSSC4j+RTqBtYfis0/F2qPUnnZyM+JDrPna9 OpUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nJ2sCcr7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id m25si1904730otn.208.2020.02.06.03.31.29; Thu, 06 Feb 2020 03:31:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nJ2sCcr7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727804AbgBFLSm (ORCPT + 99 others); Thu, 6 Feb 2020 06:18:42 -0500 Received: from mail-oi1-f194.google.com ([209.85.167.194]:46512 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727649AbgBFLSl (ORCPT ); Thu, 6 Feb 2020 06:18:41 -0500 Received: by mail-oi1-f194.google.com with SMTP id a22so4165062oid.13 for ; Thu, 06 Feb 2020 03:18:41 -0800 (PST) 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=dYQuztr5x7HOTEbo7y727kXqDcOFz4Xay/pJ3yDZkOc=; b=nJ2sCcr7VGOXE/AGUV1PHd0w5o+dEwmm9WveatUop3DxNVgCiY8VJA3/MGX1Z76kC/ hX+6VntHCNmi1bAZGjQBMMvyuxHXNv6u0k6kYVlxtrrN3MnAELiG2z6Cl2ZPOHA/QtMx LMWHrhb7XN3Yhpph3DtCYQvgdOoJrD6UGf+zU= 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=dYQuztr5x7HOTEbo7y727kXqDcOFz4Xay/pJ3yDZkOc=; b=fHxuAlSQ86u4KnlJHQkQT7awzPRYsnaRduZ8tOsiyp3hmznZ7eVPbrOey0YrU1ot6I 5MxPvgtPEMKS2Qd2E1q0bhZJTGMd+5vT/aPH8qw1lSMwNDb+5Zr9lfcFkZoR80QGlN/w 4gdw3wYwgqqSFJVbZ3WHwUCZFi2Dkq25BkqryNQNKSygH/wUCqXfQUeaUTVkwf+F3e/Q KsjggmmPjkeri3hucsFju+rTcx4g9255NV2EE0mHj3omAfVWgbRe7tQWcXCzWRFyvyIK snLlvjTgG/MxNoOkiZ5vKoY5DAjk/zv9vizx5zY6n/QC6kj/hcebYJs5g+ct43hOIb/a gqgA== X-Gm-Message-State: APjAAAX7IclMACqjYNkcOuBPiQfFr4TlUHii7G9LJTpg4TEoJozDFLto 6SymQTUXp8KvGYRwoH57CcuTbwRmPF0= X-Received: by 2002:aca:ab52:: with SMTP id u79mr6205614oie.145.1580987920960; Thu, 06 Feb 2020 03:18:40 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id j24sm1025130otk.7.2020.02.06.03.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2020 03:18:40 -0800 (PST) Date: Thu, 6 Feb 2020 03:18:38 -0800 From: Kees Cook To: Arvind Sankar Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] x86/boot/compressed/64: Remove .bss/.pgtable from bzImage Message-ID: <202002060316.A0027DEB@keescook> References: <20200109150218.16544-1-nivedita@alum.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200109150218.16544-1-nivedita@alum.mit.edu> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 09, 2020 at 10:02:17AM -0500, Arvind Sankar wrote: > Commit 5b11f1cee579 ("x86, boot: straighten out ranges to copy/zero in > compressed/head*.S") introduced a separate .pgtable section, splitting > it out from the rest of .bss. This section was added without the > writeable flag, marking it as read-only. This results in the linker > putting the .rela.dyn section (containing bogus dynamic relocations from > head_64.o) after the .bss and .pgtable sections. Thank you! As you know from the fg-kaslr thread[1], I ran into this (10 year old!) bug while helping there. I could not figure out why .bss was getting allocated into the on-disk image. > When we use objcopy to convert compressed/vmlinux into a binary for the > bzImage, the .bss and .pgtable sections get materialized as ~176KiB of > zero bytes in the binary in order to place .rela.dyn at the correct > location. > > Fix this by marking .pgtable as writeable. This moves the .rela.dyn > section earlier so that .bss and .pgtable are the last allocated > sections and so don't appear in bzImage. > > Signed-off-by: Arvind Sankar Acked-by: Kees Cook -Kees [1] https://lore.kernel.org/lkml/202002060251.681292DE63@keescook/ -- Kees Cook