[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/41] megasas: do not read iovec count more than onc
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 09/41] megasas: do not read iovec count more than once from frame |
Date: |
Thu, 15 Jun 2017 12:52:29 +0200 |
Avoid TOC-TOU bugs depending on how the compiler behaves.
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/scsi/megasas.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index 1888118..c353118 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -675,15 +675,16 @@ out:
static int megasas_map_dcmd(MegasasState *s, MegasasCmd *cmd)
{
dma_addr_t iov_pa, iov_size;
+ int iov_count;
cmd->flags = le16_to_cpu(cmd->frame->header.flags);
- if (!cmd->frame->header.sge_count) {
+ iov_count = cmd->frame->header.sge_count;
+ if (!iov_count) {
trace_megasas_dcmd_zero_sge(cmd->index);
cmd->iov_size = 0;
return 0;
- } else if (cmd->frame->header.sge_count > 1) {
- trace_megasas_dcmd_invalid_sge(cmd->index,
- cmd->frame->header.sge_count);
+ } else if (iov_count > 1) {
+ trace_megasas_dcmd_invalid_sge(cmd->index, iov_count);
cmd->iov_size = 0;
return -EINVAL;
}
--
1.8.3.1
- [Qemu-devel] [PULL 00/41] Misc patches for 2017-06-15, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 01/41] exec: check kvm mmu notifiers earlier, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 03/41] exec: split qemu_ram_alloc_from_file(), Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 02/41] exec: split file_ram_alloc(), Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 04/41] Add memory_region_init_ram_from_fd(), Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 08/41] megasas: do not read sense length more than once from frame, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 06/41] memory: remove memory_region_set_fd, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 12/41] megasas: do not read SCSI req parameters more than once from frame, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 16/41] kvm-all: make async_safe_run_on_cpu safe on kvm too, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 09/41] megasas: do not read iovec count more than once from frame,
Paolo Bonzini <=
- [Qemu-devel] [PULL 14/41] Makefile: Do not generate files if "configure" has not been run yet, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 21/41] tcg: move tcg related files into accel/tcg/ subdirectory, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 20/41] accel: split the tcg accelerator from accel.c file, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 22/41] tcg: move tcg backend files into accel/tcg/, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 17/41] hax-all: make async_safe_run_on_cpu safe on HAX too, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 13/41] megasas: always store SCSIRequest* into MegasasCmd, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 15/41] vl: Fix broken thread=xxx option of the --accel parameter, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 25/41] nbd: make nbd_drop public, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 23/41] accel: move kvm related accelerator files into accel/, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 26/41] nbd/server: get rid of nbd_negotiate_read and friends, Paolo Bonzini, 2017/06/15