Stefan Weil 68bd348ade scsi: Add assertion for use-after-free errors
The QEMU emulation which is currently used with Raspberry PI images
(qemu-system-arm -M versatilepb ...) accesses memory which was freed.

Valgrind output (extract):

==17857== Invalid write of size 4
==17857==    at 0x24EB06: scsi_req_unref (scsi-bus.c:1273)
==17857==    by 0x24FFAE: scsi_read_complete (scsi-disk.c:277)
==17857==    by 0x152ACC: bdrv_co_em_bh (block.c:3363)
==17857==    by 0x13D49C: qemu_bh_poll (async.c:71)
==17857==    by 0x211A8C: main_loop_wait (main-loop.c:503)
==17857==    by 0x207954: main_loop (vl.c:1555)
==17857==    by 0x20E9C9: main (vl.c:3653)
==17857==  Address 0x1c54383c is 12 bytes inside a block of size 260 free'd
==17857==    at 0x4824B3A: free (vg_replace_malloc.c:366)
==17857==    by 0x20ADFA: free_and_trace (vl.c:2250)
==17857==    by 0x4899FC5: g_free (in /lib/libglib-2.0.so.0.2400.1)
==17857==    by 0x24EB3B: scsi_req_unref (scsi-bus.c:1277)
==17857==    by 0x24F003: scsi_req_complete (scsi-bus.c:1383)
==17857==    by 0x25022A: scsi_read_data (scsi-disk.c:334)
==17857==    by 0x24EB9F: scsi_req_continue (scsi-bus.c:1289)
==17857==    by 0x1C7787: lsi_do_dma (lsi53c895a.c:575)
==17857==    by 0x1C8CDA: lsi_execute_script (lsi53c895a.c:1147)
==17857==    by 0x1C74EA: lsi_resume_script (lsi53c895a.c:510)
==17857==    by 0x1C7ECD: lsi_transfer_data (lsi53c895a.c:746)
==17857==    by 0x24EC90: scsi_req_data (scsi-bus.c:1307)

(There are some more similar messages.)

This patch adds an assertion which also detects those errors:

Calling scsi_req_unref is not allowed when the previous call
of that function has decremented refcount to 0, because in this
case req was freed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-05-07 08:44:21 +02:00
2012-04-25 21:04:57 +04:00
2012-04-13 09:57:36 +01:00
2012-05-01 00:17:27 +02:00
2012-05-02 18:39:39 +02:00
2012-04-12 19:01:42 -03:00
2012-05-01 19:08:44 -03:00
2012-05-01 10:58:04 +00:00
2012-04-17 10:51:41 +02:00
2012-04-26 13:14:58 -05:00
2012-04-19 18:52:48 +00:00
2012-04-07 14:00:45 +00:00
2012-04-19 16:51:47 +02:00
2012-03-14 22:20:25 +01:00
2012-04-27 11:44:50 -03:00
2012-04-19 16:29:33 +02:00
2012-02-09 16:17:51 +01:00
2012-03-12 10:30:23 +00:00
2012-05-01 10:45:02 +00:00
2012-03-03 18:10:16 +00:00
2012-04-15 21:25:16 +02:00
2012-03-30 08:14:11 -05:00
2012-03-07 13:03:51 +00:00
2012-04-01 20:30:23 +02:00
2012-03-14 22:20:27 +01:00
2012-03-14 22:20:27 +01:00
2012-03-15 10:39:52 -03:00
2012-03-14 22:20:27 +01:00
2012-03-14 22:20:27 +01:00
2012-04-09 14:35:25 -03:00
2012-03-19 15:17:21 +02:00
2012-04-12 19:01:41 -03:00
2012-04-12 19:01:41 -03:00
2012-03-14 22:20:26 +01:00
2012-04-26 13:14:58 -05:00
2012-03-15 10:39:52 -03:00
2012-03-15 10:39:52 -03:00
2012-02-15 09:39:21 -06:00
2012-03-27 09:15:28 -03:00
2012-02-24 13:36:04 -06:00
2012-04-19 17:19:37 +02:00
2012-03-16 01:04:51 +02:00
2012-03-16 01:04:51 +02:00
2012-02-17 08:33:32 -06:00
2012-02-17 08:33:32 -06:00
2012-04-26 13:14:58 -05:00
2012-03-14 22:20:27 +01:00
2012-04-07 14:00:45 +00:00
2012-02-03 10:41:08 -06:00
2012-03-02 11:56:38 +00:00
2012-05-01 00:17:27 +02:00
2012-04-19 16:29:33 +02:00
2012-04-19 17:19:37 +02:00
2012-04-15 21:25:16 +02:00
2012-04-07 14:00:45 +00:00
2012-05-01 00:17:27 +02:00
2012-04-26 13:14:58 -05:00
2012-04-05 14:54:40 +02:00
2012-04-05 14:54:40 +02:00
2012-04-24 09:50:31 -05:00
2012-03-14 22:20:27 +01:00
2012-03-15 10:39:52 -03:00
2012-05-02 07:32:09 -05:00

Read the documentation in qemu-doc.html or on http://wiki.qemu.org

- QEMU team
Description
No description provided
Readme 404 MiB
Languages
C 82.6%
C++ 6.5%
Python 3.4%
Dylan 2.9%
Shell 1.6%
Other 2.8%