]> xenbits.xensource.com Git - people/dariof/xen.git/commit
x86/hvm/dmop: only copy what is needed to/from the guest
authorRoss Lagerwall <ross.lagerwall@citrix.com>
Thu, 15 Feb 2018 17:16:17 +0000 (18:16 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 15 Feb 2018 17:16:17 +0000 (18:16 +0100)
commit85cb15dfe4d13b9b8b0f39a9cb257525c0b74c60
treeb75f8327189099a446a3716c0a0f72cdaa7e4030
parent5e6984c50bc7147398474fea0e6b8dc7364b91b5
x86/hvm/dmop: only copy what is needed to/from the guest

dm_op() fails with -EFAULT if the struct xen_dm_op given by the guest is
smaller than Xen's struct xen_dm_op. This is a problem because DMOP is
meant to be a stable ABI but it breaks whenever the size of struct
xen_dm_op changes.

To fix this, change how the copying to and from the guest is done. When
copying from the guest, first copy the header and inspect the op. Then,
only copy the correct amount needed for that op. When copying to the
guest, don't copy the header. Rather, copy only the correct amount
needed for that particular op.

So now the dm_op() will fail if the guest does not supply enough bytes
for the specific op. It will not fail if the guest supplies too many
bytes for the specific op, but Xen will not copy the extra bytes.

Remove some now unused macros and helper functions.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/hvm/dm.c