Patchwork [6/7] scsi-disk: improve out-of-range LBA detection for WRITE SAME

login
register
mail settings
Submitter Paolo Bonzini
Date Aug. 9, 2012, 1:38 p.m.
Message ID <1344519511-18147-7-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/176114/
State New
Headers show

Comments

Paolo Bonzini - Aug. 9, 2012, 1:38 p.m.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi-disk.c | 3 ++-
 1 file modificato, 2 inserzioni(+). 1 rimozione(-)

Patch

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 3baa238..dd7ae6d 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1712,7 +1712,8 @@  static int32_t scsi_disk_emulate_command(SCSIRequest *req, uint8_t *buf)
             scsi_check_condition(r, SENSE_CODE(WRITE_PROTECTED));
             return 0;
         }
-        if (r->req.cmd.lba > s->qdev.max_lba) {
+        if (r->req.cmd.lba > r->req.cmd.lba + nb_sectors ||
+            r->req.cmd.lba + nb_sectors - 1 > s->qdev.max_lba) {
             goto illegal_lba;
         }