qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] scsi: Change scsi sense buf size to 252
@ 2014-01-24  7:02 Fam Zheng
  2014-01-26  6:11 ` Benoît Canet
  0 siblings, 1 reply; 3+ messages in thread
From: Fam Zheng @ 2014-01-24  7:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini

Current buffer size fails the assersion check in like

    hw/scsi/scsi-bus.c:1655:    assert(req->sense_len <= sizeof(req->sense));

when backend (block/iscsi.c) returns more data then 96.

Exercise the core dump path by booting an Gentoo ISO with scsi-generic
device backed with iscsi (built with libiscsi 1.7.0):

    x86_64-softmmu/qemu-system-x86_64 \
    -drive file=iscsi://localhost:3260/iqn.foobar/0,if=none,id=drive-disk \
    -device virtio-scsi-pci,id=scsi1,bus=pci.0,addr=0x6 \
    -device scsi-generic,drive=drive-disk,bus=scsi1.0,id=iscsi-disk \
    -boot d \
    -cdrom gentoo.iso

    qemu-system-x86_64: hw/scsi/scsi-bus.c:1655: scsi_req_complete:
    Assertion `req->sense_len <= sizeof(req->sense)' failed.

According to SPC-4, section 4.5.2.1, 252 is the limit of sense data. So
increase the value to fix it.

Also remove duplicated define for the macro.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 hw/scsi/scsi-generic.c | 2 --
 hw/scsi/spapr_vscsi.c  | 1 -
 include/hw/scsi/scsi.h | 2 +-
 3 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 8f195be..4967e47 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -37,8 +37,6 @@ do { fprintf(stderr, "scsi-generic: " fmt , ## __VA_ARGS__); } while (0)
 #include <scsi/sg.h>
 #include "block/scsi.h"
 
-#define SCSI_SENSE_BUF_SIZE 96
-
 #define SG_ERR_DRIVER_TIMEOUT  0x06
 #define SG_ERR_DRIVER_SENSE    0x08
 
diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c
index c0c46d7..e8bca39 100644
--- a/hw/scsi/spapr_vscsi.c
+++ b/hw/scsi/spapr_vscsi.c
@@ -60,7 +60,6 @@
 #define VSCSI_MAX_SECTORS       4096
 #define VSCSI_REQ_LIMIT         24
 
-#define SCSI_SENSE_BUF_SIZE     96
 #define SRP_RSP_SENSE_DATA_LEN  18
 
 typedef union vscsi_crq {
diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
index bf6da3d..ca66454 100644
--- a/include/hw/scsi/scsi.h
+++ b/include/hw/scsi/scsi.h
@@ -31,7 +31,7 @@ typedef struct SCSISense {
     uint8_t ascq;
 } SCSISense;
 
-#define SCSI_SENSE_BUF_SIZE 96
+#define SCSI_SENSE_BUF_SIZE 252
 
 struct SCSICommand {
     uint8_t buf[SCSI_CMD_BUF_SIZE];
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] scsi: Change scsi sense buf size to 252
  2014-01-24  7:02 [Qemu-devel] [PATCH] scsi: Change scsi sense buf size to 252 Fam Zheng
@ 2014-01-26  6:11 ` Benoît Canet
  2014-01-27 13:14   ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Benoît Canet @ 2014-01-26  6:11 UTC (permalink / raw)
  To: Fam Zheng; +Cc: Paolo Bonzini, qemu-devel

Le Friday 24 Jan 2014 à 15:02:24 (+0800), Fam Zheng a écrit :
> Current buffer size fails the assersion check in like
> 
>     hw/scsi/scsi-bus.c:1655:    assert(req->sense_len <= sizeof(req->sense));
> 
> when backend (block/iscsi.c) returns more data then 96.
> 
> Exercise the core dump path by booting an Gentoo ISO with scsi-generic
> device backed with iscsi (built with libiscsi 1.7.0):
> 
>     x86_64-softmmu/qemu-system-x86_64 \
>     -drive file=iscsi://localhost:3260/iqn.foobar/0,if=none,id=drive-disk \
>     -device virtio-scsi-pci,id=scsi1,bus=pci.0,addr=0x6 \
>     -device scsi-generic,drive=drive-disk,bus=scsi1.0,id=iscsi-disk \
>     -boot d \
>     -cdrom gentoo.iso
> 
>     qemu-system-x86_64: hw/scsi/scsi-bus.c:1655: scsi_req_complete:
>     Assertion `req->sense_len <= sizeof(req->sense)' failed.
> 
> According to SPC-4, section 4.5.2.1, 252 is the limit of sense data. So
> increase the value to fix it.
> 
> Also remove duplicated define for the macro.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  hw/scsi/scsi-generic.c | 2 --
>  hw/scsi/spapr_vscsi.c  | 1 -
>  include/hw/scsi/scsi.h | 2 +-
>  3 files changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
> index 8f195be..4967e47 100644
> --- a/hw/scsi/scsi-generic.c
> +++ b/hw/scsi/scsi-generic.c
> @@ -37,8 +37,6 @@ do { fprintf(stderr, "scsi-generic: " fmt , ## __VA_ARGS__); } while (0)
>  #include <scsi/sg.h>
>  #include "block/scsi.h"
>  
> -#define SCSI_SENSE_BUF_SIZE 96
> -
>  #define SG_ERR_DRIVER_TIMEOUT  0x06
>  #define SG_ERR_DRIVER_SENSE    0x08
>  
> diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c
> index c0c46d7..e8bca39 100644
> --- a/hw/scsi/spapr_vscsi.c
> +++ b/hw/scsi/spapr_vscsi.c
> @@ -60,7 +60,6 @@
>  #define VSCSI_MAX_SECTORS       4096
>  #define VSCSI_REQ_LIMIT         24
>  
> -#define SCSI_SENSE_BUF_SIZE     96
>  #define SRP_RSP_SENSE_DATA_LEN  18
>  
>  typedef union vscsi_crq {
> diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
> index bf6da3d..ca66454 100644
> --- a/include/hw/scsi/scsi.h
> +++ b/include/hw/scsi/scsi.h
> @@ -31,7 +31,7 @@ typedef struct SCSISense {
>      uint8_t ascq;
>  } SCSISense;
>  
> -#define SCSI_SENSE_BUF_SIZE 96
> +#define SCSI_SENSE_BUF_SIZE 252
>  
>  struct SCSICommand {
>      uint8_t buf[SCSI_CMD_BUF_SIZE];
> -- 
> 1.8.5.3
> 
> 
Reviewed-by: Benoit Canet <benoit@irqsave.net>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] scsi: Change scsi sense buf size to 252
  2014-01-26  6:11 ` Benoît Canet
@ 2014-01-27 13:14   ` Paolo Bonzini
  0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2014-01-27 13:14 UTC (permalink / raw)
  To: Benoît Canet, Fam Zheng; +Cc: qemu-devel

Il 26/01/2014 07:11, Benoît Canet ha scritto:
> Le Friday 24 Jan 2014 à 15:02:24 (+0800), Fam Zheng a écrit :
>> Current buffer size fails the assersion check in like
>>
>>     hw/scsi/scsi-bus.c:1655:    assert(req->sense_len <= sizeof(req->sense));
>>
>> when backend (block/iscsi.c) returns more data then 96.
>>
>> Exercise the core dump path by booting an Gentoo ISO with scsi-generic
>> device backed with iscsi (built with libiscsi 1.7.0):
>>
>>     x86_64-softmmu/qemu-system-x86_64 \
>>     -drive file=iscsi://localhost:3260/iqn.foobar/0,if=none,id=drive-disk \
>>     -device virtio-scsi-pci,id=scsi1,bus=pci.0,addr=0x6 \
>>     -device scsi-generic,drive=drive-disk,bus=scsi1.0,id=iscsi-disk \
>>     -boot d \
>>     -cdrom gentoo.iso
>>
>>     qemu-system-x86_64: hw/scsi/scsi-bus.c:1655: scsi_req_complete:
>>     Assertion `req->sense_len <= sizeof(req->sense)' failed.
>>
>> According to SPC-4, section 4.5.2.1, 252 is the limit of sense data. So
>> increase the value to fix it.
>>
>> Also remove duplicated define for the macro.
>>
>> Signed-off-by: Fam Zheng <famz@redhat.com>

Applied to scsi-next, thanks!

Paolo

>> ---
>>  hw/scsi/scsi-generic.c | 2 --
>>  hw/scsi/spapr_vscsi.c  | 1 -
>>  include/hw/scsi/scsi.h | 2 +-
>>  3 files changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
>> index 8f195be..4967e47 100644
>> --- a/hw/scsi/scsi-generic.c
>> +++ b/hw/scsi/scsi-generic.c
>> @@ -37,8 +37,6 @@ do { fprintf(stderr, "scsi-generic: " fmt , ## __VA_ARGS__); } while (0)
>>  #include <scsi/sg.h>
>>  #include "block/scsi.h"
>>
>> -#define SCSI_SENSE_BUF_SIZE 96
>> -
>>  #define SG_ERR_DRIVER_TIMEOUT  0x06
>>  #define SG_ERR_DRIVER_SENSE    0x08
>>
>> diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c
>> index c0c46d7..e8bca39 100644
>> --- a/hw/scsi/spapr_vscsi.c
>> +++ b/hw/scsi/spapr_vscsi.c
>> @@ -60,7 +60,6 @@
>>  #define VSCSI_MAX_SECTORS       4096
>>  #define VSCSI_REQ_LIMIT         24
>>
>> -#define SCSI_SENSE_BUF_SIZE     96
>>  #define SRP_RSP_SENSE_DATA_LEN  18
>>
>>  typedef union vscsi_crq {
>> diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
>> index bf6da3d..ca66454 100644
>> --- a/include/hw/scsi/scsi.h
>> +++ b/include/hw/scsi/scsi.h
>> @@ -31,7 +31,7 @@ typedef struct SCSISense {
>>      uint8_t ascq;
>>  } SCSISense;
>>
>> -#define SCSI_SENSE_BUF_SIZE 96
>> +#define SCSI_SENSE_BUF_SIZE 252
>>
>>  struct SCSICommand {
>>      uint8_t buf[SCSI_CMD_BUF_SIZE];
>> --
>> 1.8.5.3
>>
>>
> Reviewed-by: Benoit Canet <benoit@irqsave.net>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-01-27 13:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-24  7:02 [Qemu-devel] [PATCH] scsi: Change scsi sense buf size to 252 Fam Zheng
2014-01-26  6:11 ` Benoît Canet
2014-01-27 13:14   ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).