Skip to content

Commit

Permalink
xen: Prevent buffer overflow in privcmd ioctl
Browse files Browse the repository at this point in the history
The "call" variable comes from the user in privcmd_ioctl_hypercall().
It's an offset into the hypercall_page[] which has (PAGE_SIZE / 32)
elements.  We need to put an upper bound on it to prevent an out of
bounds access.

Cc: [email protected]
Fixes: 1246ae0 ("xen: add variable hypercall caller")
Signed-off-by: Dan Carpenter <[email protected]>
Reviewed-by: Boris Ostrovsky <[email protected]>
Signed-off-by: Juergen Gross <[email protected]>
  • Loading branch information
Dan Carpenter authored and jgross1 committed Apr 5, 2019
1 parent ad94dc3 commit 42d8644
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arch/x86/include/asm/xen/hypercall.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ xen_single_call(unsigned int call,
__HYPERCALL_DECLS;
__HYPERCALL_5ARG(a1, a2, a3, a4, a5);

if (call >= PAGE_SIZE / sizeof(hypercall_page[0]))
return -EINVAL;

asm volatile(CALL_NOSPEC
: __HYPERCALL_5PARAM
: [thunk_target] "a" (&hypercall_page[call])
Expand Down

0 comments on commit 42d8644

Please sign in to comment.