From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x227N5OOT/2Vw5dSJVqaB1v4ZyZGD9KDTYaLx8pQQICHYgUFAo+cTJkSO0F5ZQGvzdcjdILrZ ARC-Seal: i=1; a=rsa-sha256; t=1517256638; cv=none; d=google.com; s=arc-20160816; b=A/aVWsFiNRs+EJs2xzQQmQPaFjnBduc8uw5rk0Y3JrE2tRuwDvVBY3BCWGo44dCmEC mcAdCt6rc0rj/zMqOYvGReDVFRBTNPIsEzVTW5LwYHT0j2MXIPY6WppDuR96yqJ/06nE PSRK/wzl8qzoEQYcSeDlA62283PELCQdKlof6JWJFGR97CIZsKk5Z+0tYKsTx8t+UOTq 3Xzjlt6xgLjoSX1AxTOVMgskwcOUfAOH1nRqy7dVgJWSmisCZs1sew2OSqsUaoDJsr7V sv5EbJuQdEoOUEptfYh4c2esNqHB4U/JsmlOSIj2nK8yW9AYmm10KyUyex4xU+2GgCjc Rh3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=huFISKgRkj9g0ah5m6S+yByUdO+F4xFv/oA4KtYfrg8=; b=q80TDkqgKAGJDuLJ2aa0sdi9YDndNl6iJWSCH5Im4cO1ezj4NbWFo6xhwM0+d981kf J3s26zcgP1nAgG/2O8Gk94uXtnxNV3aqCS09mjLiRplfdCqD2RGU5bdW43bt0k5q7g1t E8scenFmhZjhr058v7J7Vpc2UH5/kKYquvBFiLsM2VOJ7uUaxA2yeYIOJqsTmTAAztw5 O1r2RotoQrMKSByflSyQ2In5chaJcstbWjMwYGdDVokUUKsdBUFjIehYvq1LY5YA1PH8 xJ0E+NAvy/zQz+rLverrHzvXxNFI3hz9GvWN1zTYJW512pZTdJO8VV+IuF6Dq8lDUa/Q PEBg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590958759039170461?= X-GMAIL-MSGID: =?utf-8?q?1590958896518546454?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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 +