From patchwork Tue May 1 22:33:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 10374577 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 811F26032A for ; Tue, 1 May 2018 22:36:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66E5828CF0 for ; Tue, 1 May 2018 22:36:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B19928D01; Tue, 1 May 2018 22:36:47 +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, 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 B03BA28CF0 for ; Tue, 1 May 2018 22:36:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 51E146B0003; Tue, 1 May 2018 18:36:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4CE0E6B0006; Tue, 1 May 2018 18:36:44 -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 3BCCF6B0007; Tue, 1 May 2018 18:36:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f71.google.com (mail-pg0-f71.google.com [74.125.83.71]) by kanga.kvack.org (Postfix) with ESMTP id F07CC6B0003 for ; Tue, 1 May 2018 18:36:43 -0400 (EDT) Received: by mail-pg0-f71.google.com with SMTP id j18-v6so8850279pgv.18 for ; Tue, 01 May 2018 15:36:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:to:cc :from:date:message-id:mime-version:content-transfer-encoding; bh=Hjby3/Kupt8uF2dxlt/s/q94l5VK25VXMqYjiFmoPm0=; b=ZUe4/MuUkNShad/EXzGIpUNWxE8mBsnT4FBhcGjfWf0wDTyEed98g6YWnSw1hIc3hH St4n3RfJaK51Nj5D9IEh59V0Dd0mQpM15kNUH/SIl4wTxL0RfLwF+dbPzkFf3F15v0oJ 3r/AS1n9wqawauvEr6DF5Ixk70vQSQsLMYHnLWZyNYLSs8OsqGmIhFnMELUWen2+0jRT w3hyfsnpeuE7sHcOIj61FAjyyklCnyFASpBc0QcCp4+mfb7eqPMryWSeziHHcz5+PfnU hKkfLqhWFqYOet5q2xnRj5EBpx0ug2SUrRklhBVCXHZ+8MlFFDWYAVMX9n+BJGp8fVtt 6Rrg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of srs0=xkju=hu=linuxfoundation.org=gregkh@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=SRS0=xkJU=HU=linuxfoundation.org=gregkh@kernel.org X-Gm-Message-State: ALQs6tBF4UU6ADImF1OsL+57vrBX3xec4koYkugXJyugwGwCg7nULrPe WbWEu9FhVYoiXM1n5/BxrmBoGQwu50yJEMq83EB9iWX2vk54S6S05KTmanjEhxqrwaNxI4OH4yV 7KQNCCiwV1rbeIIbjlP/ZHCke+rX6Nj3EM28hUJgiIV3ceSAE78YkkjMgqmgn+Hc= X-Received: by 10.167.130.22 with SMTP id k22mr17238034pfi.73.1525214203593; Tue, 01 May 2018 15:36:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZruZNh+BqJ4HGZB31znaCPC6jBediX4yZSZ+dNY3QZgJUecxdhKMSGFWNUw/SWm+dpoVc1y X-Received: by 10.167.130.22 with SMTP id k22mr17238013pfi.73.1525214202842; Tue, 01 May 2018 15:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525214202; cv=none; d=google.com; s=arc-20160816; b=HUIykAmCez5s/0eDBIUT8bpMWqwnLnkb3TdOeCfy5AiO6p88NVxO6dBkB9D9BL+gZV 3M0I+5NLXLonbAnNaEfW0PWz3Nw7S9xsfEcNvXj3ItnAEzfA9y1pSLxF63N49s2Ch7j/ 7+Ae+rlVoxLeDz2oifuuTPepasEFXseIs6OnHB6L2Pl4Q7EnOUVsdCG2YIQA95c9oA37 VFFyRDOTsKP+WUOi3LE06FNxSMuItg47BgFYn2sK7Y/O19KOdT11DrkLDujpfhPBM6FI 7acyWbOj7SeHawg7gGKbwMKQUFXnYOGP8rp3WlrENbrCIj0ToWg1j93oRpR8o6gCryAE g/0w== 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:arc-authentication-results; bh=Hjby3/Kupt8uF2dxlt/s/q94l5VK25VXMqYjiFmoPm0=; b=dpsv2E1n/uopnXqwNOKYd4zYyPlCVBdCfrk5gg+CjltVKjvSy7/5QWyW5FcJUw0gZL 5jZzfgyyP0DfLfeByXBtOxXR5mMTyc3r7sp4tM8D6+WRBVyDY9Fl/frV+8SWhq6XSVyH PN2i+no5bRFDaXDVLo4IT7p/3uckQ5shb5/eqtGu1Fx0s829j66dqC9xRwDzlJiY+B9W pLaslUpzRLLZOciImP7V1yh3wNv4/MQM2WcKxWQbmDY5rL1Rv3sbOTHlGkFNz+l3LUZZ OkqrVNXjThfNqwgnUSqxCso2y3jzkYCo3MzAsEyWyaMaC4N8KswXS6EoCgPvci/EqHE2 VV+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of srs0=xkju=hu=linuxfoundation.org=gregkh@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=SRS0=xkJU=HU=linuxfoundation.org=gregkh@kernel.org Received: from mail.kernel.org (mail.kernel.org. [198.145.29.99]) by mx.google.com with ESMTPS id z11-v6si8459477pgz.412.2018.05.01.15.36.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 15:36:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of srs0=xkju=hu=linuxfoundation.org=gregkh@kernel.org designates 198.145.29.99 as permitted sender) client-ip=198.145.29.99; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of srs0=xkju=hu=linuxfoundation.org=gregkh@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=SRS0=xkJU=HU=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 27FF823753; Tue, 1 May 2018 22:36:42 +0000 (UTC) Subject: Patch "x86/mm: Do not forbid _PAGE_RW before init for __ro_after_init" has been added to the 4.16-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: Tue, 01 May 2018 15:33:11 -0700 Message-ID: <1525213991150176@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.16-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.16 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. From foo@baz Tue May 1 14:59:17 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.16/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 @@ -298,9 +298,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;