]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.35/xen-prevent-buffer-overflow-in-privcmd-ioctl.patch
Linux 4.19.35
[thirdparty/kernel/stable-queue.git] / releases / 4.19.35 / xen-prevent-buffer-overflow-in-privcmd-ioctl.patch
CommitLineData
d33cec38
GKH
1From 42d8644bd77dd2d747e004e367cb0c895a606f39 Mon Sep 17 00:00:00 2001
2From: Dan Carpenter <dan.carpenter@oracle.com>
3Date: Thu, 4 Apr 2019 18:12:17 +0300
4Subject: xen: Prevent buffer overflow in privcmd ioctl
5
6From: Dan Carpenter <dan.carpenter@oracle.com>
7
8commit 42d8644bd77dd2d747e004e367cb0c895a606f39 upstream.
9
10The "call" variable comes from the user in privcmd_ioctl_hypercall().
11It's an offset into the hypercall_page[] which has (PAGE_SIZE / 32)
12elements. We need to put an upper bound on it to prevent an out of
13bounds access.
14
15Cc: stable@vger.kernel.org
16Fixes: 1246ae0bb992 ("xen: add variable hypercall caller")
17Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
18Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
19Signed-off-by: Juergen Gross <jgross@suse.com>
20Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21
22---
23 arch/x86/include/asm/xen/hypercall.h | 3 +++
24 1 file changed, 3 insertions(+)
25
26--- a/arch/x86/include/asm/xen/hypercall.h
27+++ b/arch/x86/include/asm/xen/hypercall.h
28@@ -206,6 +206,9 @@ xen_single_call(unsigned int call,
29 __HYPERCALL_DECLS;
30 __HYPERCALL_5ARG(a1, a2, a3, a4, a5);
31
32+ if (call >= PAGE_SIZE / sizeof(hypercall_page[0]))
33+ return -EINVAL;
34+
35 asm volatile(CALL_NOSPEC
36 : __HYPERCALL_5PARAM
37 : [thunk_target] "a" (&hypercall_page[call])