From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x225QbT9nj66RstCTJ3uwzB5IBPtUmZsi7oMZG1/Jn01RiCHKVkQBbd/uzb3roeXCJfNYR15Q ARC-Seal: i=1; a=rsa-sha256; t=1517256506; cv=none; d=google.com; s=arc-20160816; b=emcAagFwKchxHWySPw6mfZK+AByEy2pa91YttKEyEMTtNiVmI/Zz0sv7ZnzpNtpD20 5VnPfkWwGGpUfi2gVt7LeATdgTjRYwypflgm4XR0hTVrxW0wZ1uzGO3xYEPn0QzNw0jk M4gYSxkW4wRhPFD3oK9CKPj5tPVhc254fWgS54j3oTfbbdUaWeF88ZwYTHyta8Oly2yK nUNzfOJVvnm/N47VfpaCvBs6cgujs6fxTlpMTgFPkwzdlQiIpKVLItHtSUPE7BJbLzLI 0x0qQrpt9GRcecN2UTOK9SC5XgR6M+9Eu8+oe55fX0fk1khuWmRC8i+wo8EcoQK9NPmc jM/g== 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=b0db0RQt7o1R7AzqyzqdO/A0dfGD27ex3D2mrdzg9n8=; b=f2R27dieyuGOSqEqvCr7pKXfol0J9DphxndXHNqXWZpVw3NNwgodN6SRK+Z3A88pHB twWjP0O0LIiw6KCA28ff6vstKRXun5YYZxqHb2TgoOBf+S28h6cdv9JE1tSwMFMq69QR wxfi+viUM13+D/066LqW68L6cJWPC2JXsbm6BNCZzedJ7PxQMxA4ZuczBxOyBPvRdejx d0/pfsZFHM1vCEQFddRidwBg4AZGa3XLnqrbV4K+cMQtcdSTfOiiZUwQVvCXr7/toZq1 36tUkNJarZnmLz3VLrMRGM3bewtbGRzWGygHm6tKRr5k1vvlIdQj+D3wieAyLrSF2j6M WsAA== 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.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 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?1590958759039170461?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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 +