xen/hypercall: Don't use BUG() for parameter checking in hypercall_create_continuation()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 31 Oct 2019 15:07:11 +0000 (16:07 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 31 Oct 2019 15:07:11 +0000 (16:07 +0100)
commit0bf9f8d3e399a0e1d2b717f71b4776172446184b
tree0182bc453350f7ffd0f10b86325bbf04b1fef4d3
parentece1d5cda17c2815dd194909569deb254ddae575
xen/hypercall: Don't use BUG() for parameter checking in hypercall_create_continuation()

Since c/s 1d429034 "hypercall: update vcpu_op to take an unsigned vcpuid",
which incorrectly swapped 'i' for 'u' in the parameter type list, guests have
been able to hit the BUG() in next_args()'s default case.

Correct these back to 'i'.

In addition, make adjustments to prevent this class of issue from occurring in
the future - crashing Xen is not an appropriate form of parameter checking.

Capitalise NEXT_ARG() to catch all uses, to highlight that it is a macro doing
non-function-like things behind the scenes, and undef it when appropriate.
Implement a bad_fmt: block which prints an error, asserts unreachable, and
crashes the guest.

On the ARM side, drop all parameter checking of p.  It is asymmetric with the
x86 side, and akin to expecting memcpy() or sprintf() to check their src/fmt
parameter before use.  A caller passing "" or something other than a string
literal will be obvious during code review.

This is XSA-296.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
xen/arch/arm/domain.c
xen/arch/x86/hypercall.c
xen/common/compat/domain.c
xen/common/domain.c