QEMU | Heap-use-after-free through ehci_flush_qh (#541)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
I'm not sure I understand. We try to avoid writing to MMIO regions in fuzz_dma_read_cb to avoid such false-positives. E.g. that's why we have code to do address_space_translate and manually walk the AddressSpace and verify that we are writing to RAM, before doing the actual qtest_memwrite. There is a fix to that code that need to be applied, but those have to wait for the 6.1 release. BTW, since this is about the generic-fuzzer rather than this bug, I cc-ed qemu-devel. Let's continue the discussion there.
-Alex
Quoted 14 lines · 李秋豪
李秋豪 commented on a discussion: https://gitlab.com/qemu-project/qemu/-/issues/541#note_657305687
Ok, I add a reply to my report about #540 and #541.
Btw, it suddenly occurred to me that our generic-fuzzer can also make reentry issues. For example, a device tries to read from a mmio region while being fuzzed, but the
fuzz_dma_read_cb()will write to that region, thus leading to positive-false reentry issues. In short, we change a read action to write. Should we add checks?Signature · 2 lines
Reply to this email directly or view it on GitLab: https://gitlab.com/qemu-project/qemu/-/issues/541#note_657305687 You're receiving this email because of your account on gitlab.com.
fuzz: fuzz_dma_read_cb() may overlap with MMIO regions
I think the check in fuzz_dma_read_cb() is buggy because it doesn't consider when the write address is not in the mmio region but can overlap. For example, the mmio region is 0xe0000000 to 0xe0001000, and the write address is 0xdffff000 (not ram) and length is 0x2000. In this case, the address_space_translate() will return the sparse_mem_mr we created, thus bypassing the check and call qtest_memwrite().
Perhaps we need more detailed checks to ensure that the entire write operation occurs in the ram or won't overlap with mmio regions. What do you think?
mr1 = address_space_translate(first_cpu->as,
addr, &addr1, &l, true,
MEMTXATTRS_UNSPECIFIED);if (!(memory_region_is_ram(mr1) ||
memory_region_is_romd(mr1)) && mr1 != sparse_mem_mr) {
l = memory_access_size(mr1, l, addr1);
} else {
/* ROM/RAM case */
// mr1 == sparse_mem_mr but it's not RAM or ROM <--
// May overlap with mmio regions <--
...
qtest_memwrite(qts_global, addr, buf, l);Thanks.
Qiuhao Li
Quoted 34 lines · Alexander Bulekov
I'm not sure I understand. We try to avoid writing to MMIO regions in
fuzz_dma_read_cbto avoid such false-positives. E.g. that's why we have code to doaddress_space_translateand manually walk the AddressSpace and verify that we are writing to RAM, before doing the actualqtest_memwrite. There is a fix to that code that need to be applied, but
those have to wait for the 6.1 release. BTW, since this is about the generic-fuzzer rather than this bug, I cc-ed qemu-devel. Let's continue the discussion there.-Alex
Quoted 20 lines · 李秋豪
李秋豪 commented on a discussion:
https://gitlab.com/qemu-project/qemu/-/issues/541#note_657305687Ok, I add a reply to my report about #540 and #541.
Btw, it suddenly occurred to me that our generic-fuzzer can also make reentry issues. For example, a device tries to read from a mmio region while being fuzzed, but the
fuzz_dma_read_cb()will write to that region, thus leading to positive-false reentry issues. In short, we change a read action to write. Should we add checks?Signature · 3 lines
Reply to this email directly or view it on GitLab: https://gitlab.com/qemu-project/qemu/-/issues/541#note_657305687 You're receiving this email because of your account on gitlab.com.
Re: fuzz: fuzz_dma_read_cb() may overlap with MMIO regions
Quoted 7 lines · Qiuhao Li
I think the check in
fuzz_dma_read_cb()is buggy because it doesn't consider when the write address is not in the mmio region but can overlap. For example, the mmio region is0xe0000000to0xe0001000, and the write address is0xdffff000(not ram) and length is0x2000. In this case, theaddress_space_translate()will return thesparse_mem_mrwe created, thus bypassing the check and callqtest_memwrite().
Quoted 5 lines
Perhaps we need more detailed checks to ensure that the entire write operation occurs in the ram or won't overlap with mmio regions. What do you think?
Good catch. I think this will fix that:
https://lore.kernel.org/qemu-devel/[email protected]/
I mentioned that there were some fixes waiting for the 6.1 release, but didn't realize you were talking about what seems to be the same issue. -Alex
Quoted 55 lines
mr1 = address_space_translate(first_cpu->as,
addr, &addr1, &l, true, MEMTXATTRS_UNSPECIFIED);if (!(memory_region_is_ram(mr1) ||
memory_region_is_romd(mr1)) && mr1 != sparse_mem_mr) { l = memory_access_size(mr1, l, addr1); } else { /* ROM/RAM case */ // mr1 == sparse_mem_mr but it's not RAM or ROM <-- // May overlap with mmio regions <-- ... qtest_memwrite(qts_global, addr, buf, l);Thanks.
Qiuhao LiQuoted 34 lines · Alexander Bulekov
I'm not sure I understand. We try to avoid writing to MMIO regions in
fuzz_dma_read_cbto avoid such false-positives. E.g. that's why we have code to doaddress_space_translateand manually walk the AddressSpace and verify that we are writing to RAM, before doing the actualqtest_memwrite. There is a fix to that code that need to be applied, but
those have to wait for the 6.1 release. BTW, since this is about the generic-fuzzer rather than this bug, I cc-ed qemu-devel. Let's continue the discussion there.-Alex
Quoted 20 lines · 李秋豪
李秋豪 commented on a discussion:
https://gitlab.com/qemu-project/qemu/-/issues/541#note_657305687Ok, I add a reply to my report about #540 and #541.
Btw, it suddenly occurred to me that our generic-fuzzer can also make reentry issues. For example, a device tries to read from a mmio region while being fuzzed, but the
fuzz_dma_read_cb()will write to that region, thus leading to positive-false reentry issues. In short, we change a read action to write. Should we add checks?Signature · 3 lines
Reply to this email directly or view it on GitLab: https://gitlab.com/qemu-project/qemu/-/issues/541#note_657305687 You're receiving this email because of your account on gitlab.com.
Re: fuzz: fuzz_dma_read_cb() may overlap with MMIO regions
Aha! Nice patch.
My fault. I will search first next time :)
Thanks.
Qiuhao Li
Quoted 27 lines · Alexander Bulekov
Quoted 10 lines · Qiuhao Li
I think the check in
fuzz_dma_read_cb()is buggy because it doesn't consider when the write address is not in the mmio region but can overlap. For example, the mmio region is0xe0000000to0xe0001000, and
the write address is0xdffff000(not ram) and length is0x2000. In this
case, theaddress_space_translate()will return thesparse_mem_mrwe
created, thus bypassing the check and callqtest_memwrite().Quoted 7 lines
Perhaps we need more detailed checks to ensure that the entire write
operation occurs in the ram or won't overlap with mmio regions. What do
you think?Good catch. I think this will fix that:
https://lore.kernel.org/qemu-devel/[email protected]/I mentioned that there were some fixes waiting for the 6.1 release, but
didn't realize you were talking about what seems to be the same issue.
-Alex
Re: fuzz: fuzz_dma_read_cb() may overlap with MMIO regions
Quoted 3 lines · Qiuhao Li
Aha! Nice patch.
My fault. I will search first next time :)
If you are interested in testing fuzzing code and you want to automatically be cc-ed when something changes, you can send a patch adding yourself to reviewers in the Fuzzing section of MAINTAINERS -Alex
Quoted 34 lines
Thanks.
Qiuhao LiQuoted 27 lines · Alexander Bulekov
Quoted 10 lines · Qiuhao Li
I think the check in
fuzz_dma_read_cb()is buggy because it doesn't consider when the write address is not in the mmio region but can overlap. For example, the mmio region is0xe0000000to0xe0001000, and
the write address is0xdffff000(not ram) and length is0x2000. In this
case, theaddress_space_translate()will return thesparse_mem_mrwe
created, thus bypassing the check and callqtest_memwrite().Quoted 7 lines
Perhaps we need more detailed checks to ensure that the entire write
operation occurs in the ram or won't overlap with mmio regions. What do
you think?Good catch. I think this will fix that:
https://lore.kernel.org/qemu-devel/[email protected]/I mentioned that there were some fixes waiting for the 6.1 release, but
didn't realize you were talking about what seems to be the same issue.
-Alex