Received: by 10.223.176.5 with SMTP id f5csp3416039wra; Mon, 29 Jan 2018 12:52:05 -0800 (PST) X-Google-Smtp-Source: AH8x226iLMGdYZ6vGSXhTTFX8fbABAQWQm0R9t5HC9GiHjoVcX1wyYnXWUv7exintuslcw72G3ly X-Received: by 10.101.101.19 with SMTP id x19mr23340304pgv.347.1517259125639; Mon, 29 Jan 2018 12:52:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517259125; cv=none; d=google.com; s=arc-20160816; b=PmdMyscJuCNZtYZXSIV56PwYv1WnGQsFucF235Hs1NT9VS9xZvzMjY9Ll43D8dZ4de jk21U+hw9+QYW8PNWav8Z8AZQolELVIhpYMX0SLXjyM7geR4kPaYURbsyyx9EuhF4GzU iPaVUuCS36bMIgPCynriRAz6ca9oJjVVQKSOOom5OzLZmALU9nKj0itc8BHfY6LingMv aC46oNN3EVfP90KTUzLopz99YUR4oFpFH0PjlZkpfcRxbulPyC+ddIbHq7yWgtGLLoqf wbdr958MblAV18x76WjzRkITvPVJmK1SxsoAdruVt9ZQU8pzDqEBZs9xHff5NY2cb+66 K3XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=huFISKgRkj9g0ah5m6S+yByUdO+F4xFv/oA4KtYfrg8=; b=DGexaPK1BNx8mrTn2TX+6eD1JgfRw5/f7mR+uBV/NZLvQWp63PZL4GnOlLt68X9k2O 15Ft8J40L6y7P7wz785cbX7vpm6arWYe3sM4L9tHSWl9WNyQLwOMQkH7vmml+HH8+bYA 0ydE3zoIvsFhBQ+2DDKVYj1kt8QkDr/foMxQcyfgG3jA+TZmhlqKRbEutvyo4QkOVCAa JlHZz+Y/ETElzEyuHrv7E3dmfzCBoB5Lvp42wsAaOHQu1CVlC9s+leyCyTpv9QuOcY4W 1QJkO5TsdNLSZRdms4je3N9TucJh3VNj73Y1pQWecyrze3B6Ksdg2ZhokVC+vMmZ6kZw 7HoA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z10si7898163pgp.671.2018.01.29.12.51.51; Mon, 29 Jan 2018 12:52:05 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753528AbeA2UKk (ORCPT + 99 others); Mon, 29 Jan 2018 15:10:40 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:57682 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753513AbeA2UKh (ORCPT ); Mon, 29 Jan 2018 15:10:37 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6AEFD2F89; Mon, 29 Jan 2018 13:05:30 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Borislav Petkov , Hugh Dickins , Ben Hutchings Subject: [PATCH 4.9 31/66] vsyscall: Fix permissions for emulate mode with KAISER/PTI Date: Mon, 29 Jan 2018 13:56:55 +0100 Message-Id: <20180129123841.486062633@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123839.842860149@linuxfoundation.org> References: <20180129123839.842860149@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ben Hutchings The backport of KAISER to 4.4 turned vsyscall emulate mode into native mode. Add a vsyscall_pgprot variable to hold the correct page protections, like Borislav and Hugh did for 3.2 and 3.18. Cc: Borislav Petkov Cc: Hugh Dickins Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- arch/x86/entry/vsyscall/vsyscall_64.c | 7 ++++--- arch/x86/include/asm/vsyscall.h | 1 + arch/x86/mm/kaiser.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) --- a/arch/x86/entry/vsyscall/vsyscall_64.c +++ b/arch/x86/entry/vsyscall/vsyscall_64.c @@ -46,6 +46,7 @@ static enum { EMULATE, NATIVE, NONE } vs #else EMULATE; #endif +unsigned long vsyscall_pgprot = __PAGE_KERNEL_VSYSCALL; static int __init vsyscall_setup(char *str) { @@ -336,11 +337,11 @@ void __init map_vsyscall(void) extern char __vsyscall_page; unsigned long physaddr_vsyscall = __pa_symbol(&__vsyscall_page); + if (vsyscall_mode != NATIVE) + vsyscall_pgprot = __PAGE_KERNEL_VVAR; if (vsyscall_mode != NONE) __set_fixmap(VSYSCALL_PAGE, physaddr_vsyscall, - vsyscall_mode == NATIVE - ? PAGE_KERNEL_VSYSCALL - : PAGE_KERNEL_VVAR); + __pgprot(vsyscall_pgprot)); BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_PAGE) != (unsigned long)VSYSCALL_ADDR); --- a/arch/x86/include/asm/vsyscall.h +++ b/arch/x86/include/asm/vsyscall.h @@ -13,6 +13,7 @@ extern void map_vsyscall(void); */ extern bool emulate_vsyscall(struct pt_regs *regs, unsigned long address); extern bool vsyscall_enabled(void); +extern unsigned long vsyscall_pgprot; #else static inline void map_vsyscall(void) {} static inline bool emulate_vsyscall(struct pt_regs *regs, unsigned long address) --- a/arch/x86/mm/kaiser.c +++ b/arch/x86/mm/kaiser.c @@ -344,7 +344,7 @@ void __init kaiser_init(void) if (vsyscall_enabled()) kaiser_add_user_map_early((void *)VSYSCALL_ADDR, PAGE_SIZE, - __PAGE_KERNEL_VSYSCALL); + vsyscall_pgprot); for_each_possible_cpu(cpu) { void *percpu_vaddr = __per_cpu_user_mapped_start +