x86/memshr: properly check grant references
authorJan Beulich <jbeulich@suse.com>
Tue, 22 Nov 2016 16:28:52 +0000 (17:28 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 22 Nov 2016 16:28:52 +0000 (17:28 +0100)
commit986f790e0184d4bf575462077378e14fa9f85aa9
tree4b9f21898e1788a471d1a53e7aad5649b5baaa88
parent1d7ecc0348741543cbfec96d4817531efcf755c3
x86/memshr: properly check grant references

They need to be range checked against the current table limit in any
event.

Reported-by: Huawei PSIRT <psirt@huawei.com>
Move the code to where it belongs, eliminating a number of duplicate
definitions. Add locking. Produce proper error codes, and consume them
instead of making one up. Check grant type. Convert parameter types at
once.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
xen/arch/x86/mm/mem_sharing.c
xen/common/grant_table.c
xen/include/xen/grant_table.h