gnttab: correct GNTTABOP_cache_flush empty batch handling
authorJan Beulich <jbeulich@suse.com>
Mon, 4 Dec 2017 10:03:32 +0000 (11:03 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 4 Dec 2017 10:03:32 +0000 (11:03 +0100)
commit9c22e4d67f5552c7c896ed83bd95d5d4c5837a9d
treef98eb83855421be2952abf86293ff612dfa249a7
parent514f58d4468a40b5dd418a5ea1742681930c3f2d
gnttab: correct GNTTABOP_cache_flush empty batch handling

Jann validly points out that with a caller bogusly requesting a zero-
element batch with non-zero high command bits (the ones used for
continuation encoding), the assertion right before the call to
hypercall_create_continuation() would trigger. A similar situation would
arise afaict for non-empty batches with op and/or length zero in every
element.

While we want the former to succeed (as we do elsewhere for similar
no-op requests), the latter can clearly be converted to an error, as
this is a state that can't be the result of a prior operation.

Take the opportunity and also correct the order of argument checks:
We shouldn't accept zero-length elements with unknown bits set in "op".
Also constify cache_flush()'s first parameter.

Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andre Przywara <andre.przywara@linaro.org>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
xen/common/grant_table.c