qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Implementing a Runtime Shadow Stack
@ 2015-11-04 20:07 Jhong Chung, Juan
  0 siblings, 0 replies; only message in thread
From: Jhong Chung, Juan @ 2015-11-04 20:07 UTC (permalink / raw)
  To: qemu-devel

Hi qemu-devel,

I’m trying to start a project and I need some guidance. I want to 
develop a runtime shadow stack for any binary executed under qemu 
regardless of the guest or host architecture. This will be a proof of 
concept for a course project. For now I don’t need to worry about 
overhead or optimization.

The basic functionality that I'm trying to implement in QEMU is to to 
save the stack pointer when I enter a function and when a function 
returns, compare the current stack pointer to the saved one in case it’s 
been modified.

I apologize in advance for my limited knowledge of QEMU development. 
Newbie here. I've been reading the documentation as much as I can.


What I understand is that for any binary executed in qemu, the guest 
architecture instructions are turned into tiny code by the TCG. Tiny 
code operations are then able to run in the host architecture.

I have two ideas to implement a runtime shadow stack:

1. Modify the binary running under QEMU and add extra guest instructions 
to save the stack pointer after “call” and add a compare instructions 
after “ret”. After that the TCG will take care of translate my newly 
added instructions to tiny code and in theory they will be executed with 
no problem in the host. Does QEMU allow modifying binaries?

2. Modify the TCG: Is it possible to modify the TCG so that when a 
“call” instruction is encounted, it generates tiny code as usual, but it 
also adds an extra function to save the stack pointer? The same idea 
applies to when the TCG encounters a “ret” guest instruction. I want to 
add an additional function that compares the return address and the 
saved stack pointer.

Which approach do you think is better/easier or possible to begin with? 
I’m leaning toward making changes to the TCG. My team and I will open 
source this project. Any pointers are appreciated!

Thanks!

Juan Jhong-Chung

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-04 20:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-04 20:07 [Qemu-devel] Implementing a Runtime Shadow Stack Jhong Chung, Juan

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