Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4869196pjb; Mon, 27 Jul 2020 07:14:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzO946PhPk9h9lXgl323wkLlZAL2S7SsmslXngOZ1vRb077x5n+hy9EvJR6+nQygsWzcW7p X-Received: by 2002:a17:906:950c:: with SMTP id u12mr20630705ejx.37.1595859257241; Mon, 27 Jul 2020 07:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595859257; cv=none; d=google.com; s=arc-20160816; b=cIoqGDmVJWM9sF4wdVcqk6gZ3hzHvT+tBDM1O/RZqxKsggh47MJdd08C6nmTzdZtoO d7No7zIKxMMKafHBKoyeJlRbd+cNi2TxcuN5eeBxX4n0kzXi6e222Bw4+FTT1y8cvYlX L7eWjlGziYqjiLij5iKCR83Y5ZSvEGRrdbcV/vQBVYmS61oGcinALX0oKjcmUx0NizR+ uE+79dSD38Uyjwh9CUn68tRhBhmn1wxhIMID2H4r5NZ+9ld8tM/+gpr2qnVUkEef+HtM bzzDVGx+9bmyU/PvqU+qv6TBHG442z4NLslNICiTBJFcnB+u9Zvng4OOA0EaqwCVwqJy ErQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rtgRv0RpfD7Ll6fNLyfOaL4RigN5DC8JZo/QB/thlL0=; b=BHV/H34t6X9hnzLLfIF787xiFlmLqgifO78BKyUYlVpXzc/Ff6uPwtOrgJ7qn2Bzie EyH6E8V/uY1Z6UGcBgyRxMh4oY6UJpGFEv10Rk7VR/0cFjVRXnFvrJiqX1bHXb636v8w JFdpDaeAy6hWEIS4KiGnsub46Br96qVB4+5m1Pcy6lOnF9y3pCxufrAiAhbKHGLWlpSK 6cZRJfi77+9/OHGbFanBERcJVYf4rZHzL1aXuAdS6IC6RkG18sffcVVH0WVoxGdVqYYK qO5ZMzEbygLymFwvNH1XQik9Faj9yKvo3RLO9NMtcqwGR2khL5jzc6RdqUv7qVbKzcZ/ 4+dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b6mciHwc; 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 y16si6202390edq.189.2020.07.27.07.13.55; Mon, 27 Jul 2020 07:14:17 -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=b6mciHwc; 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 S1730204AbgG0OM2 (ORCPT + 99 others); Mon, 27 Jul 2020 10:12:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:36560 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730189AbgG0OMU (ORCPT ); Mon, 27 Jul 2020 10:12:20 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D2F6A20838; Mon, 27 Jul 2020 14:12:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859140; bh=dc5GIlP5hZ2l58dr+lnG1k9qkoosoB/+ERd84z3QCqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b6mciHwcRd9ypKEBZMSPBA0aQO/6t+yYCX+LXaCpMrMOYmq1IPdtQVJAvk/V1cE5x x3aybnaAHR+XrXkcn7NZfGTCqHkWm+u4iziPYOqdOht8Ds7sdHcjSYsKDZIM1sfU74 b3h6C6xR8dF/wGjp3YKKCJ005TBcAaZ/3kXEShJs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joerg Roedel , Thomas Gleixner , Kees Cook Subject: [PATCH 4.19 81/86] x86, vmlinux.lds: Page-align end of ..page_aligned sections Date: Mon, 27 Jul 2020 16:04:55 +0200 Message-Id: <20200727134918.465504233@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134914.312934924@linuxfoundation.org> References: <20200727134914.312934924@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel commit de2b41be8fcccb2f5b6c480d35df590476344201 upstream. On x86-32 the idt_table with 256 entries needs only 2048 bytes. It is page-aligned, but the end of the .bss..page_aligned section is not guaranteed to be page-aligned. As a result, objects from other .bss sections may end up on the same 4k page as the idt_table, and will accidentially get mapped read-only during boot, causing unexpected page-faults when the kernel writes to them. This could be worked around by making the objects in the page aligned sections page sized, but that's wrong. Explicit sections which store only page aligned objects have an implicit guarantee that the object is alone in the page in which it is placed. That works for all objects except the last one. That's inconsistent. Enforcing page sized objects for these sections would wreckage memory sanitizers, because the object becomes artificially larger than it should be and out of bound access becomes legit. Align the end of the .bss..page_aligned and .data..page_aligned section on page-size so all objects places in these sections are guaranteed to have their own page. [ tglx: Amended changelog ] Signed-off-by: Joerg Roedel Signed-off-by: Thomas Gleixner Reviewed-by: Kees Cook Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20200721093448.10417-1-joro@8bytes.org Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/vmlinux.lds.S | 1 + include/asm-generic/vmlinux.lds.h | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -372,6 +372,7 @@ SECTIONS .bss : AT(ADDR(.bss) - LOAD_OFFSET) { __bss_start = .; *(.bss..page_aligned) + . = ALIGN(PAGE_SIZE); *(BSS_MAIN) BSS_DECRYPTED . = ALIGN(PAGE_SIZE); --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -279,7 +279,8 @@ #define PAGE_ALIGNED_DATA(page_align) \ . = ALIGN(page_align); \ - *(.data..page_aligned) + *(.data..page_aligned) \ + . = ALIGN(page_align); #define READ_MOSTLY_DATA(align) \ . = ALIGN(align); \ @@ -650,7 +651,9 @@ . = ALIGN(bss_align); \ .bss : AT(ADDR(.bss) - LOAD_OFFSET) { \ BSS_FIRST_SECTIONS \ + . = ALIGN(PAGE_SIZE); \ *(.bss..page_aligned) \ + . = ALIGN(PAGE_SIZE); \ *(.dynbss) \ *(BSS_MAIN) \ *(COMMON) \