From patchwork Wed Jul 11 11:29:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10519505 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 2AB106032A for ; Wed, 11 Jul 2018 11:32:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E27A26861 for ; Wed, 11 Jul 2018 11:32:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21964284B3; Wed, 11 Jul 2018 11:32:03 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable 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 C75A626861 for ; Wed, 11 Jul 2018 11:32:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D65B6B028D; Wed, 11 Jul 2018 07:30:20 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7ADB96B0290; Wed, 11 Jul 2018 07:30:20 -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 5FD4E6B028F; Wed, 11 Jul 2018 07:30:20 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id 022496B028D for ; Wed, 11 Jul 2018 07:30:20 -0400 (EDT) Received: by mail-ed1-f69.google.com with SMTP id w10-v6so9792639eds.7 for ; Wed, 11 Jul 2018 04:30:19 -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:from:to:cc:subject:date :message-id:in-reply-to:references; bh=yudYNyn1Lxan+E5J+81h1NnRe9DFfy1ORIbUjMxHj1k=; b=qtaGTosXTZhVnNgIKIeAfoASQoDSDekFVZgN0ixRE8PRed2VDIsHFO00UgkiVjMvav HMlXZUb8UCMyVjm+Q3lJQ8l8gWgkfB7eHQumR8UVMcpiIi6wqYRF+e1sbp0o1X4RgazK A5y9s4a8Cmvu89dYzkh71T3ad1+JillHdInpEtIQ5VCGljSCJxgLDV4sx7qaYMZbZxkg ohe97pn0ZoUFMV/RW63fTqjdvybCt1q5t/c+NKBwJAlP4CfTAxlxIBW8aGkkpmRqSVo0 /9fH4uD072VRIwDzz/FujTPoi2ra852ZX+4vksohUxuJ7B8SDZAs8Cqg/8C1mTHu8rcw 4PFw== X-Gm-Message-State: APt69E2ed48YyqucUo7/Rw2N6sMO3DfXPmlIfi2MBHTr5N8KT2jD6BTi 3JVyIP2y36AsWWCM3L/ilNqABAoxMTkKXZ305hXpIFO55OS4qTGJ+UtcILGt3/YHrvRWKSHWy5q pEAbLJxPpw1stzl/s8BwxKDCr9zu0Lcm/9x/aC1ZhG/sLfwn8WbmDFD9a9zeVFDO7Cg== X-Received: by 2002:a50:baae:: with SMTP id x43-v6mr30414496ede.65.1531308619575; Wed, 11 Jul 2018 04:30:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdvGtP4N1jj+1vA921rmoCtonUHjApUtupo1MJASMwEpQS0M7ejgGSULaNdR/0UJ7codDJM X-Received: by 2002:a50:baae:: with SMTP id x43-v6mr30414462ede.65.1531308618989; Wed, 11 Jul 2018 04:30:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531308618; cv=none; d=google.com; s=arc-20160816; b=FkAbJjKQryjj/3tH7CTCIfudN+Q3uBKkSPKXXjcFrgqVkPPSP0YmW+bJNJex4vSMPV VoCbJsF8PXSj5dPDDHuxaqLeFDDK8MoUXUJp8C1HpNhOReomlazAO8J0rhOzZfuOJv0X 3HWaGY7mcJ14glCqi4FUxa2gzZ788kWWC84w6AFlaKsUHvV+r90AU7QWmXFf5Gy0GLOt 3GS1VLZpM2yfmv7KEJD/JbBR6Mltbtruji92vMoPd78iR/Vn9ChVGva9ccURr8nnAygs y89TqAqSddaHTkEQAqIAuFgihZQy0IorUoj48kQeyFzGuyX+WSnlWiI980MXYnO6krva kLEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=yudYNyn1Lxan+E5J+81h1NnRe9DFfy1ORIbUjMxHj1k=; b=FX4zEmfWC4QjaP0MfPxFHjW7+H8QmutE1Rhz46uQ2e/n7zI3YqNp+kS4Oeciu4cgif 5dblecUkaEZ7gPetM9tkcSeLcOASgFS/bkKsjwDlQNQFaAWK7RHKB9ou5TcDCKOnSqe+ rwtnsUR5mF9TneUAQb7DJipYfNDGGBdV68uwex2CjrMSpxWHl5RDHLb57eDAIUxM10XR mwObPZuPMwnpnAkDp12Bde2x3j5cKbKTc4ZrCORwto0fbwRHV9QNK1TN0jG5oSKOgiSz LLOoDoE4ZPIRHSk/sDQhzW2CQPxdvGsCnmsJaTfdWy9eV52tJflpJnAMHKNc0/p1AYXs G8zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=I6PCcwfo; spf=pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: from theia.8bytes.org (8bytes.org. [81.169.241.247]) by mx.google.com with ESMTPS id w10-v6si3190514edi.69.2018.07.11.04.30.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jul 2018 04:30:18 -0700 (PDT) Received-SPF: pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) client-ip=81.169.241.247; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=I6PCcwfo; spf=pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: by theia.8bytes.org (Postfix, from userid 1000) id 30944306F; Wed, 11 Jul 2018 13:30:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1531308607; bh=dfv0Zih1QJqgNawf7FbV+BW/CZ/u7bR2eHjCpA2aoNE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I6PCcwfoUJP0V1FltHewvANzNLt9DdlFM8x96hxSJ30yPSoqKtNnWN4rotOwQPrWg 17LmacJdb9tv/jFhexsiE7kpeDVak/SQK8o8te+QpWaUOBkt39nvt+4cf2zZVQKRYk PAbVHsSKoVTDRe2MP1qZTooqxUyDr8DrVkIVJCcdo+EsS1EgAj0bWy9AENqZ8fQZQe K+O6MhX+tIeklBsVcMs3D1PxBOHLkcKFxszcE0WAWU3dGap2LQpLMhcUvWHJ2SRE7B wUVPRgd7uoCLHVX9Zrf9ufZPBGJxSCuT+b6uJy9vAzDGouZJ8/ZVsv9JqHlOIgBfIq HwRFqJxgBg/MA== From: Joerg Roedel To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Andy Lutomirski , Dave Hansen , Josh Poimboeuf , Juergen Gross , Peter Zijlstra , Borislav Petkov , Jiri Kosina , Boris Ostrovsky , Brian Gerst , David Laight , Denys Vlasenko , Eduardo Valentin , Greg KH , Will Deacon , aliguori@amazon.com, daniel.gruss@iaik.tugraz.at, hughd@google.com, keescook@google.com, Andrea Arcangeli , Waiman Long , Pavel Machek , "David H . Gutteridge" , jroedel@suse.de, joro@8bytes.org Subject: [PATCH 28/39] x86/mm/pti: Keep permissions when cloning kernel text in pti_clone_kernel_text() Date: Wed, 11 Jul 2018 13:29:35 +0200 Message-Id: <1531308586-29340-29-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531308586-29340-1-git-send-email-joro@8bytes.org> References: <1531308586-29340-1-git-send-email-joro@8bytes.org> 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 From: Joerg Roedel Mapping the kernel text area to user-space makes only sense if it has the same permissions as in the kernel page-table. If permissions are different this will cause a TLB reload when using the kernel page-table, which is as good as not mapping it at all. On 64-bit kernels this patch makes no difference, as the whole range cloned by pti_clone_kernel_text() is mapped RO anyway. On 32 bit there are writeable mappings in the range, so just keep the permissions as they are. Signed-off-by: Joerg Roedel Reviewed-by: Andy Lutomirski --- arch/x86/mm/pti.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c index 4f6e933..fc77054 100644 --- a/arch/x86/mm/pti.c +++ b/arch/x86/mm/pti.c @@ -482,7 +482,7 @@ void pti_clone_kernel_text(void) * pti_set_kernel_image_nonglobal() did to clear the * global bit. */ - pti_clone_pmds(start, end, _PAGE_RW); + pti_clone_pmds(start, end, 0); } /*