Received: by 10.223.176.5 with SMTP id f5csp3425094wra; Mon, 29 Jan 2018 13:00:48 -0800 (PST) X-Google-Smtp-Source: AH8x224x/XR2gbNgxJlxkWgWhPQ68MekEfprhabAIbc+wOHM7L9bwUj76wUrGuR7gMQiUXbber4y X-Received: by 2002:a17:902:2cc1:: with SMTP id n59-v6mr22525018plb.153.1517259648622; Mon, 29 Jan 2018 13:00:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517259648; cv=none; d=google.com; s=arc-20160816; b=JNnKf+8kogtbwKulJjiXn3nb1gvxSE6J1U5Be+a2fsUGxyuR2UNP2G8dhdm4EFlIyK kIFiResqXoD97ZllZ/VEAq133y+bZTstEBsFanklljIyFoWAnagxQRXJgRJ/sVxT2QEO pcvxi9FEgx4/8+UZNFS6TxjpsL8iIHrixU2dhd0hNblrRUDj5WJEb1sB/tpctORO8Fna Q0ioUc59C1AvczL8bcvBC9641vEtT8vjl/QFbmSitZIyjzNRvExl6xh7l8y8U/r9F56m L+Yuw9euvjzjtcO03N2etcF/bTGerv53NO6tezMV7PkPk72zcLOqPkReu20oGJD3O2G3 +5SQ== 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=b0db0RQt7o1R7AzqyzqdO/A0dfGD27ex3D2mrdzg9n8=; b=kH2TFxiFzEqKApCpxWHy7KbED+M3hhAm9zHIOEJbPP/jYBjFUPBlweFoadvwCaNmFU qiOMPf5BhpWgrWUXBG3+951fZlzTAPtQeLU+jTXK79Pck91Fojs7VFsZW1nvitLWgS2K hNQ4ZY+Hngnk3U+35AnaJcd2h6W+P4Y5HwhUXtgx47a39GHWINGGEljqvtU8k938o3M9 ZR/IY2Kx8Exm+IUl+zKq8TGIai7fK9Kmo9zZTZPXXqwVBFAainpKvHvh8OgFz4CN3Gd5 1Qr6SwJxkj3cIM/GiQzHCJwsHu+rXlKtQEGBmiA2xaZm1DU+UCcnCqlGI4YU9KqVKsrY fSqg== 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 h23si2025302pfh.80.2018.01.29.13.00.33; Mon, 29 Jan 2018 13:00:48 -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 S1753130AbeA2UIb (ORCPT + 99 others); Mon, 29 Jan 2018 15:08:31 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:52690 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753078AbeA2UIZ (ORCPT ); Mon, 29 Jan 2018 15:08:25 -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 31F7F2F4D; Mon, 29 Jan 2018 13:03:56 +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.4 54/74] vsyscall: Fix permissions for emulate mode with KAISER/PTI Date: Mon, 29 Jan 2018 13:56:59 +0100 Message-Id: <20180129123850.025653060@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123847.507563674@linuxfoundation.org> References: <20180129123847.507563674@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.4-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 @@ -345,7 +345,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 +