Skip to contentSkip to conversation

QEMU testing methodology & results

Qemu-devel Roberto Paleari 7 participants 10 messages Apr 8, 2011 – Apr 29, 2011

lore
Share & tools
lore
#0 lore raw

Dear QEMU developers,

we are a group of researchers working at the University of Milan, Italy. During the last year we focused on automatic techniques to find defects inside CPU emulators and virtualizers. Our work has been published in different conference papers [1][2][3], and the testing methodologies we developed allowed us to find defects in several emulators and virtualizers, including QEMU.

In these days we were asked to publicly release our experimental results. As these results also include several defects in QEMU, we believed it was better to contact you before releasing this material to the public.

For this reason, we ask to whom it may concern to contact us privately at [email protected] to discuss about the disclosure of these results.

Thank you very much for your help,

Footnotes:
[1] Testing CPU Emulators (http://roberto.greyhats.it/pubs/issta09.pdf)
[2] Testing system virtual machines
(http://roberto.greyhats.it/pubs/issta10-kemufuzzer.pdf)
[3] A fistful of red-pills: How to automatically generate procedures to detect CPU emulators (http://roberto.greyhats.it/pubs/woot09.pdf)

Signature · 3 lines
Roberto Paleari
http://roberto.greyhats.it/
PGP Key Fingerprint: F94C 1933 F61C 3948 7CDD  2C61 38C7 6116 833D D6A0
#1 lore raw
Quoted 8 lines · Roberto Paleari

Dear QEMU developers,

we are a group of researchers working at the University of Milan, Italy. During the last year we focused on automatic techniques to find defects inside CPU emulators and virtualizers. Our work has been published in different conference papers [1][2][3], and the testing methodologies we developed allowed us to find defects in several emulators and virtualizers, including QEMU.

Very interesting!

The test case generation is a bit like crashme program, but more intelligent. It would be nice to integrate something like this to QEMU as a test suite instead of manually written assembly programs.

KEmuFuzzer seems to be more general. The approach of the patch is a bit intrusive. But there are similarities with it and GDB interface, tracepoints and other instrumentation needs, so it may be possible to work out a common solution.

I don't think it is possible to avoid red pills. Even with the fastest hardware assisted emulator, it may be possible to make a program to detect systematic distortions in the clock speed. Lack of cache emulation may be easy to detect. The devices that QEMU provides are so old that a machine with those devices can be considered to be QEMU by the red pill. And so on.

Quoted 8 lines

In these days we were asked to publicly release our experimental results. As these results also include several defects in QEMU, we believed it was better to contact you before releasing this material to the public.

For this reason, we ask to whom it may concern to contact us privately at [email protected] to discuss about the disclosure of these results.

I'd vote for full disclosure and open discussion on this list, but I suppose the distro people may have business interests to protect. Though the papers may already give the black hats enough ideas how to find the defects.

#2 lore raw
Quoted 1 line · Blue Swirl

Very interesting!

Thank you!

Quoted 4 lines

KEmuFuzzer seems to be more general. The approach of the patch is a bit intrusive. But there are similarities with it and GDB interface, tracepoints and other instrumentation needs, so it may be possible to work out a common solution.

Yes, KEmuFuzzer is more general and more effective than EmuFuzzer, as it can be also used to test privileged instruction.

Quoted 6 lines

I don't think it is possible to avoid red pills. Even with the fastest hardware assisted emulator, it may be possible to make a program to detect systematic distortions in the clock speed. Lack of cache emulation may be easy to detect. The devices that QEMU provides are so old that a machine with those devices can be considered to be QEMU by the red pill. And so on.

I agree: it would be really difficult to avoid red pills at all. However, in EmuFuzzer and KEmuFuzzer we are interested only in "instruction-level" red pills. I mean, we focused only on possibile defects in the implementation of the instruction semantics, so we do not take into account possibile red pills caused by clock skews, device IDs, and so on.

Quoted 4 lines

I'd vote for full disclosure and open discussion on this list, but I suppose the distro people may have business interests to protect. Though the papers may already give the black hats enough ideas how to find the defects.

I agree: the papers already disclose some details that could allow "black hats" to re-implement the same approaches and eventualy find emulation defects. However, we prefered to contact QEMU developers before disclosing the details of the defects we found.

Thank you!
Roberto

Signature · 3 lines
Roberto Paleari
http://roberto.greyhats.it/
PGP Key Fingerprint: F94C 1933 F61C 3948 7CDD  2C61 38C7 6116 833D D6A0
#3 lore raw
In reply to Roberto Paleari
Quoted 3 lines · Roberto Paleari

For this reason, we ask to whom it may concern to contact us privately at [email protected] to discuss about the disclosure of these results.

Hi Roberto,
Any update? Did a qemu.git committer contact you in order to handle the issues you found?

Stefan

#4 lore raw

Hi Stefan,

Not yet. I have not received any reply besides Blue Swirl's message..

Roberto

Quoted 3 lines · Stefan Hajnoczi

Hi Roberto,
Any update?  Did a qemu.git committer contact you in order to handle the issues you found?

#5 lore raw
Quoted 3 lines · Roberto Paleari

Hi Stefan,

Not yet. I have not received any reply besides Blue Swirl's message..

Therefore, please publish the problems you found on this list so we can start fixing them.

#6 lore raw
In reply to Roberto Paleari
Quoted 9 lines · Roberto Paleari

Dear QEMU developers,

we are a group of researchers working at the University of Milan, Italy. During the last year we focused on automatic techniques to find defects inside CPU emulators and virtualizers. Our work has been published in different conference papers [1][2][3], and the testing methodologies we developed allowed us to find defects in several emulators and virtualizers, including QEMU.

Quoted 4 lines

In these days we were asked to publicly release our experimental results. As these results also include several defects in QEMU, we believed it was better to contact you before releasing this material to the public.

Just to be clear, at least for x86 CPU emulation, QEMU does not attempt to achieve perfect fidelity and has some pretty well known "security" issues. For instance, it does not emulate segment register limits in any meaningful way.

This does not mean that the guest can break into the host, just that the guest protection mechanisms aren't always enforced when using TCG.

This is not an issue with KVM though.

Regards,

Anthony Liguori

Quoted 14 lines

For this reason, we ask to whom it may concern to contact us privately at [email protected] to discuss about the disclosure of these results.

Thank you very much for your help,

Footnotes:
[1] Testing CPU Emulators (http://roberto.greyhats.it/pubs/issta09.pdf)
[2] Testing system virtual machines
(http://roberto.greyhats.it/pubs/issta10-kemufuzzer.pdf)
[3] A fistful of red-pills: How to automatically generate procedures to detect CPU emulators (http://roberto.greyhats.it/pubs/woot09.pdf)

#7 lore raw
Quoted 2 lines · Anthony Liguori

Just to be clear, at least for x86 CPU emulation, QEMU does not attempt to achieve perfect fidelity

Also true for ARM CPU emulation. The theoretical aim there as far as I'm concerned is architectural correctness -- in other words we should be a valid implementation of the architecture, but where the architecture says things are UNPREDICTABLE or IMPLEMENTATION DEFINED we don't necessarily do what any particular real hardware implementation does. Device accuracy [ie "if modelling an A8, do what an A8 does"] is not really done at all beyond the really obvious things like ID registers.

-- PMM

#8 lore raw
Quoted 3 lines · Peter Maydell

The theoretical aim there as far
as I'm concerned is architectural correctness -- in other words we should be a valid implementation of the architecture,

That's not even the case for x86. It should be a goal, however, that with mainstream kernels user programs shouldn't be able to see the difference. There are some known issues besides bugs, for example the "instruction pointer of the last FP instruction" register (!) is not implemented.

Paolo

#9 lore raw
Quoted 10 lines · Paolo Bonzini
Quoted 4 lines · Peter Maydell

The theoretical aim there as far
as I'm concerned is architectural correctness -- in other words we should be a valid implementation of the architecture,

That's not even the case for x86.  It should be a goal, however, that with mainstream kernels user programs shouldn't be able to see the difference. There are some known issues besides bugs, for example the "instruction pointer of the last FP instruction" register (!) is not implemented.

For Sparc32 userland, I think the emulator is pretty close to correct (or at least it could be very precise) since the instruction set is so simple and there are very few corner cases. Maybe also for Sparc64, where the set is not so simple anymore.

Still, things like order of exceptions may be tricky to implement correctly. FPUs in QEMU execute synchronously to integer units.

Another case is that TCG needs to keep TBs and the instructions which were used to generate the TBs in synch to support PC search (usually this is needed anyway for example to support SMC on x86), but on Sparc it should be possible to execute old code from cache while the instructions have been modified in memory and no barrier instructions have been issued.