diff options
author | Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> | 2022-07-30 13:26:56 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2022-08-01 15:22:39 +0200 |
commit | 55794c904df723109b228da28b5db778e0df3110 (patch) | |
tree | 38c20583260471c78820164d2c4e63a656cf9236 /softmmu | |
parent | 54a53a006ed9c1fe027fd89045d6de1e9128d7f4 (diff) |
scsi-disk: ensure block size is non-zero and changes limited to bits 8-15
The existing code assumes that the block size can be generated from p[1] << 8
in multiple places which ignores the top and bottom 8 bits. If the block size
is allowed to be set to an arbitrary value then this causes a mismatch
between the value written by the guest in the block descriptor and the value
subsequently read back using READ CAPACITY causing the guest to generate
requests that can crash QEMU.
For now restrict block size changes to bits 8-15 and also ignore requests to
set the block size to 0 which causes the SCSI emulation to crash in at least
one place with a divide by zero error.
Fixes: 356c4c441e ("scsi-disk: allow MODE SELECT block descriptor to set the block size")
Closes: https://gitlab.com/qemu-project/qemu/-/issues/1112
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Message-Id: <20220730122656.253448-3-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'softmmu')
0 files changed, 0 insertions, 0 deletions