From patchwork Wed May 2 19:04:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10376321 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 331596038F for ; Wed, 2 May 2018 19:07:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 228A228F74 for ; Wed, 2 May 2018 19:07:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1644528F78; Wed, 2 May 2018 19:07:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 654A628F74 for ; Wed, 2 May 2018 19:07:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 726866B0003; Wed, 2 May 2018 15:07:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5779E6B0009; Wed, 2 May 2018 15:07:25 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 417586B000A; Wed, 2 May 2018 15:07:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f72.google.com (mail-pg0-f72.google.com [74.125.83.72]) by kanga.kvack.org (Postfix) with ESMTP id E5C3A6B0009 for ; Wed, 2 May 2018 15:07:24 -0400 (EDT) Received: by mail-pg0-f72.google.com with SMTP id m13-v6so10753677pgp.5 for ; Wed, 02 May 2018 12:07:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:to:cc:from:date :message-id:mime-version:content-transfer-encoding; bh=JIrIN3EVSTLb8eudkqRTSBGpa0Kj13Ub5DSOvu+fito=; b=SS2cPQqE0SQB8StaYGdCqbcLBGKj2IxS5tWD4wSMwNUgagpvUuGwIK9dmQmjV0TElY SZqdjhdPBgYRP9ziPWxV1yp6XGyDlC5iPvpUykeWzqdy6mKg+YQxvpQkuKTXXsVj+7Vr EoZIfXSEjbFf+eCHbcbsCQLo81ydEHgj4nn7A8GyM0uIbC8uTOXxgHe17L1Yi4wW1R5p 5BPj8rZGutsJHCJhJuyKystsmq4rubXAg7DWNMAYpM2SUOiosersjPr8nGzcJioMfDyl jpn1QXxOddTbcsVc1UNm62VU++j7FH64ZBZYjMO1GDtJvkyA2y8x4rdoxTnSg8BeWzuo CD+A== X-Gm-Message-State: ALQs6tB8BkZFl9VhKQpkzzo+L1b8aumASxubeHSZZdxWQKOfzfPdFlDx z2fE43AvRsAPVeZRBQFZRNLPWa2QW/6JVnuQWcRD0RR5E648EGkLg3/6uxvq2Xdu3hwNBPcGTu9 FxfXDZgPIxsafecfa0XDYffT99AyapG2biJkuRKY3BuNc6WrOsphvDN/VzDLGCCw= X-Received: by 2002:a17:902:8692:: with SMTP id g18-v6mr21211529plo.152.1525288044195; Wed, 02 May 2018 12:07:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrBCbLG4uPFS1YSQT3FqqnMsfBZHhBMFZ1olpV2P3fB3VMYB95BNZO9claRhSHg06fqTh0t X-Received: by 2002:a17:902:8692:: with SMTP id g18-v6mr21211491plo.152.1525288043320; Wed, 02 May 2018 12:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525288043; cv=none; d=google.com; s=arc-20160816; b=CxeSm0rkuYXMuo49b6egRahG0/oJdMsRxZ7dyxbJULjxCjsA6PU2n6c8qgcpqccMPx yQ0JxV8on0cOqV7sqqlbMXUKy6vS8LqI94Q9dj8dNNBKNL/bEIkcBKrgxFE6F2beatxU pfGN2zozMsIiKHesPo9VFkTIRWEC1R+Pxeqqb0ZYiDYYrz41e/WuFPFcB6W9Y0q1p1IE 26+9PO9cue01qnAgWuJid3prQ47rielx10Spbc+Y6nG3eCprlOINbxJZB1N4x3ciiqdQ I7nsGL8I+7oX3TmoH6xXUwZjgo/p6dHC1jYp9Cf9GsVlvxlq0M8ZQZPbT9yJMthgkyrc 02GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:from:cc:to :subject:dkim-signature:arc-authentication-results; bh=JIrIN3EVSTLb8eudkqRTSBGpa0Kj13Ub5DSOvu+fito=; b=NtPhQ//MmPDKH70huryz8RGPWsXUpkiBpaim91K1IWdHQnZUjK0gSPq0S5hsfLtmwZ rGb0GnId44QVzy9/PpqdJwGPF924nijyuD89CDZWnEVs5M/BRH9XFbAYnGqK+3Y4uhhG S5cn78H/kPlBXS1Sr8QJQyKK+rYa+dhAVSqiXw9C3V/8bvJWZ6sm6PYNpOfhCO7vfUYe x+TQyU8yoN+ZJrzNiP1SgSrFM739AeXkr7eBL8RukrYwVZ05aj2c2etLMrT1RkJpOpGL yKiJ5eZH/UcGsjguJHgYzMAL+CKjXl3SHgPq7nO1f1WptqTMLJYpM0XShRkhb+HsOwPi zLVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2lSIHFOu; spf=pass (google.com: domain of srs0=nwvz=hv=linuxfoundation.org=gregkh@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=SRS0=nwvz=HV=linuxfoundation.org=gregkh@kernel.org Received: from mail.kernel.org (mail.kernel.org. [198.145.29.99]) by mx.google.com with ESMTPS id ay8-v6si12224996plb.244.2018.05.02.12.07.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 May 2018 12:07:23 -0700 (PDT) Received-SPF: pass (google.com: domain of srs0=nwvz=hv=linuxfoundation.org=gregkh@kernel.org designates 198.145.29.99 as permitted sender) client-ip=198.145.29.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2lSIHFOu; spf=pass (google.com: domain of srs0=nwvz=hv=linuxfoundation.org=gregkh@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=SRS0=nwvz=HV=linuxfoundation.org=gregkh@kernel.org Received: from localhost (unknown [104.132.1.102]) (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 9110B23957; Wed, 2 May 2018 19:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1525288042; bh=GPn5/l1IV0+BvvbAbImW1P/KYr+iM0QOcEeAWHYBZkA=; h=Subject:To:Cc:From:Date:From; b=2lSIHFOubQ4NZQIAxvFsr43ypOJNeHb/gBTC7h4tWYTZrq3HcE7LMNwvf5+aES0Fz Xltak2fxZE1poyfdzN5LWuP256l/KfOww8nVNhK+pJUWAObgRdnxpGEH0uB8MwtNaT 7BggtmRvEF3P8IpvwkqjtZX+aSfAkj9Hl3nKCsAI= Subject: Patch "x86/mm: Do not forbid _PAGE_RW before init for __ro_after_init" has been added to the 4.4-stable tree To: 20180406205514.8D898241@viggo.jf.intel.com, aarcange@redhat.com, alexander.levin@microsoft.com, arjan@linux.intel.com, bp@alien8.de, dan.j.williams@intel.com, dave.hansen@linux.intel.com, dwmw2@infradead.org, gregkh@linuxfoundation.org, hughd@google.com, jgross@suse.com, jpoimboe@redhat.com, keescook@chromium.org, linux-mm@kvack.org, luto@kernel.org, mingo@kernel.org, namit@vmware.com, peterz@infradead.org, tglx@linutronix.de, torvalds@linux-foundation.org Cc: From: Date: Wed, 02 May 2018 12:04:18 -0700 Message-ID: <1525287858124153@kroah.com> MIME-Version: 1.0 X-stable: commit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This is a note to let you know that I've just added the patch titled x86/mm: Do not forbid _PAGE_RW before init for __ro_after_init to the 4.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: x86-mm-do-not-forbid-_page_rw-before-init-for-__ro_after_init.patch and it can be found in the queue-4.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. From foo@baz Wed May 2 11:39:22 PDT 2018 From: Dave Hansen Date: Fri, 6 Apr 2018 13:55:14 -0700 Subject: x86/mm: Do not forbid _PAGE_RW before init for __ro_after_init From: Dave Hansen [ Upstream commit 639d6aafe437a7464399d2a77d006049053df06f ] __ro_after_init data gets stuck in the .rodata section. That's normally fine because the kernel itself manages the R/W properties. But, if we run __change_page_attr() on an area which is __ro_after_init, the .rodata checks will trigger and force the area to be immediately read-only, even if it is early-ish in boot. This caused problems when trying to clear the _PAGE_GLOBAL bit for these area in the PTI code: it cleared _PAGE_GLOBAL like I asked, but also took it up on itself to clear _PAGE_RW. The kernel then oopses the next time it wrote to a __ro_after_init data structure. To fix this, add the kernel_set_to_readonly check, just like we have for kernel text, just a few lines below in this function. Signed-off-by: Dave Hansen Acked-by: Kees Cook Cc: Andrea Arcangeli Cc: Andy Lutomirski Cc: Arjan van de Ven Cc: Borislav Petkov Cc: Dan Williams Cc: David Woodhouse Cc: Greg Kroah-Hartman Cc: Hugh Dickins Cc: Josh Poimboeuf Cc: Juergen Gross Cc: Linus Torvalds Cc: Nadav Amit Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/20180406205514.8D898241@viggo.jf.intel.com Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/x86/mm/pageattr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) Patches currently in stable-queue which might be from dave.hansen@linux.intel.com are queue-4.4/x86-mm-do-not-forbid-_page_rw-before-init-for-__ro_after_init.patch --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -273,9 +273,11 @@ static inline pgprot_t static_protection /* * The .rodata section needs to be read-only. Using the pfn - * catches all aliases. + * catches all aliases. This also includes __ro_after_init, + * so do not enforce until kernel_set_to_readonly is true. */ - if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT, + if (kernel_set_to_readonly && + within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT, __pa_symbol(__end_rodata) >> PAGE_SHIFT)) pgprot_val(forbidden) |= _PAGE_RW;