[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PULL 32/46] scsi: provide general-purpose functions to
From: |
Roman Kagan |
Subject: |
Re: [Qemu-devel] [PULL 32/46] scsi: provide general-purpose functions to manage sense data |
Date: |
Fri, 22 Dec 2017 18:25:53 +0300 |
User-agent: |
Mutt/1.9.1 (2017-09-22) |
On Wed, Dec 20, 2017 at 06:14:44PM +0100, Paolo Bonzini wrote:
> @@ -274,52 +319,21 @@ const struct SCSISense sense_code_SPACE_ALLOC_FAILED = {
> int scsi_convert_sense(uint8_t *in_buf, int in_len,
> uint8_t *buf, int len, bool fixed)
> {
> - bool fixed_in;
> SCSISense sense;
> - if (!fixed && len < 8) {
> - return 0;
> - }
> -
> - if (in_len == 0) {
> - sense.key = NO_SENSE;
> - sense.asc = 0;
> - sense.ascq = 0;
> - } else {
> - fixed_in = (in_buf[0] & 2) == 0;
> -
> - if (fixed == fixed_in) {
> - memcpy(buf, in_buf, MIN(len, in_len));
> - return MIN(len, in_len);
> - }
> + bool fixed_in;
>
> - if (fixed_in) {
> - sense.key = in_buf[2];
> - sense.asc = in_buf[12];
> - sense.ascq = in_buf[13];
> - } else {
> - sense.key = in_buf[1];
> - sense.asc = in_buf[2];
> - sense.ascq = in_buf[3];
> - }
> + fixed_in = (in_buf[0] & 2) == 0;
> + if (in_len && fixed == fixed_in) {
> + memcpy(buf, in_buf, MIN(len, in_len));
> + return MIN(len, in_len);
This reliably segfaults with any scsi disk because
scsi_disk_emulate_command passes in_buf=NULL here:
case REQUEST_SENSE:
/* Just return "NO SENSE". */
buflen = scsi_convert_sense(NULL, 0, outbuf, r->buflen,
(req->cmd.buf[1] & 1) == 0);
Roman.
- [Qemu-devel] [PULL 23/46] tests/boot-serial-test: Add a test for the moxiesim machine, (continued)
- [Qemu-devel] [PULL 23/46] tests/boot-serial-test: Add a test for the moxiesim machine, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 26/46] cpu: suffix cpu address spaces with cpu index, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 25/46] cpu: refactor cpu_address_space_init(), Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 29/46] exec: Don't reuse unassigned_mem_ops for io_mem_rom, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 27/46] block/iscsi: dont leave allocmap in an invalid state on UNMAP failure, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 28/46] block/iscsi: only report an iSCSI Failure if we don't handle it gracefully, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 30/46] hw/mips/boston: Remove workaround for writes to ROM aborting, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 31/46] hw/i386/vmport: replace fprintf() by trace events or LOG_UNIMP, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 33/46] scsi: replace hex constants with #defines, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 32/46] scsi: provide general-purpose functions to manage sense data, Paolo Bonzini, 2017/12/20
- Re: [Qemu-devel] [PULL 32/46] scsi: provide general-purpose functions to manage sense data,
Roman Kagan <=
- [Qemu-devel] [PULL 37/46] i8259: generalize statistics into common code, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 35/46] i8259: convert DPRINTFs into trace, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 38/46] kvm-i8259: support "info pic" and "info irq", Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 36/46] i8259: use DEBUG_IRQ_COUNT always, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 34/46] Remove legacy -no-kvm-pit option, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 39/46] i8259: move TYPE_INTERRUPT_STATS_PROVIDER upper, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 40/46] checkpatch: volatile with a comment or sig_atomic_t is okay, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 43/46] test: add some chardev mux event tests, Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 41/46] rcu: reduce more than 7MB heap memory by malloc_trim(), Paolo Bonzini, 2017/12/20
- [Qemu-devel] [PULL 42/46] chardev: fix backend events regression with mux chardev, Paolo Bonzini, 2017/12/20