scsi: validate ADDITIONAL LENGTH alignment from READ KEYS
PATCH 1/1 scsi: validate ADDITIONAL LENGTH alignment from READ KEYS
A malicious host SCSI device could report a bogus ADDITIONAL LENGTH value, causing a memcmp() up to 7 bytes beyond the end of the heap buffer.
This does not seem to be a practical way to extract the contents of QEMU's memory since it only happens once per live migration and each migration destination is a new QEMU process. It doesn't hurt to protect against it though.
Reported-by Kevin Wolf <[email protected]>
Signed-off-by Stefan Hajnoczi <[email protected]>
--- hw/scsi/scsi-generic.c | 7 +++++++ 1 file changed, 7 insertions(+)
hw/scsi/scsi-generic.c +7 -0
@@ -522,6 +522,13 @@ static bool scsi_generic_pr_key_registered(SCSIDevice *s, uint64_t key,memcpy (&additional_length, &buf[4 ],sizeof (additional_length));be32_to_cpus (&additional_length); +/* The reservation key list consists of 8-byte elements */ +if (additional_length %sizeof (key_be)) { +error_setg (errp,"got misaligned ADDITIONAL LENGTH %" PRIu32 +" from READ KEYS" , additional_length); +return false; + } +/* * The parameter data's ADDITIONAL LENGTH must not overflow the CDB's * 16-bit ALLOCATION LENGTH field since the next loop iteration will
Signature · 1 line
2.54.0