qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/2] block: vpc - prevent overflow
@ 2015-07-21 16:13 Jeff Cody
  2015-07-21 16:13 ` [Qemu-devel] [PATCH v2 1/2] block: vpc - prevent overflow if max_table_entries >= 0x40000000 Jeff Cody
  2015-07-21 16:13 ` [Qemu-devel] [PATCH v2 2/2] block: qemu-iotests - add check for multiplication overflow in vpc Jeff Cody
  0 siblings, 2 replies; 8+ messages in thread
From: Jeff Cody @ 2015-07-21 16:13 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel, stefanha

Changes:

v2 now also checks that Max Table Entries is < SIZE_MAX / 4 (Thanks Stefan)

This series fixes a bug found by Richard Jones.

When we allocate the pagetable based on max_table_entries, we multiply
the max table entry value by 4 to accomodate a table of 32-bit integers.
However, max_table_entries is a uint32_t, and the VPC driver accepts
ranges for that entry over 0x40000000.  So during this allocation:

s->pagetable = qemu_try_blockalign(bs->file, s->max_table_entries * 4);

The size arg overflows, allocating significantly less memory than
expected.

Since qemu_try_blockalign() size argument is size_t, cast the
multiplication correctly to prevent overflow.

The value of "max_table_entries * 4" is used elsewhere in the code as
well, so store the correct value for use in all those cases.

Jeff Cody (2):
  block: vpc - prevent overflow if max_table_entries >= 0x40000000
  block: qemu-iotests - add check for multiplication overflow in vpc

 block/vpc.c                                   |  17 ++++++--
 tests/qemu-iotests/135                        |  54 ++++++++++++++++++++++++++
 tests/qemu-iotests/135.out                    |   5 +++
 tests/qemu-iotests/group                      |   1 +
 tests/qemu-iotests/sample_images/afl5.img.bz2 | Bin 0 -> 175 bytes
 5 files changed, 73 insertions(+), 4 deletions(-)
 create mode 100755 tests/qemu-iotests/135
 create mode 100644 tests/qemu-iotests/135.out
 create mode 100644 tests/qemu-iotests/sample_images/afl5.img.bz2

-- 
1.9.3

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

end of thread, other threads:[~2015-07-22 18:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-21 16:13 [Qemu-devel] [PATCH v2 0/2] block: vpc - prevent overflow Jeff Cody
2015-07-21 16:13 ` [Qemu-devel] [PATCH v2 1/2] block: vpc - prevent overflow if max_table_entries >= 0x40000000 Jeff Cody
2015-07-22 17:02   ` [Qemu-devel] [Qemu-block] " Max Reitz
2015-07-22 17:26     ` Jeff Cody
2015-07-22 17:29       ` Max Reitz
2015-07-22 17:40         ` Jeff Cody
2015-07-22 18:00           ` Max Reitz
2015-07-21 16:13 ` [Qemu-devel] [PATCH v2 2/2] block: qemu-iotests - add check for multiplication overflow in vpc Jeff Cody

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).