-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SpecFuzz pass: Don't instrument MFENCE instructions #19
Conversation
Before this change, the SpecFuzz pass would fail to compile code that used MFENCEs because it is treated as a write instruction with no memory operands by LLVM. This patch skips instrumenting MFENCEs. In the future, it might make sense to have SpecFuzz respond in some way to MFENCEs, but for now, skipping them is a decent workaround.
Related issue: #18 |
* The main file in the examples folder is named demo.c rather than main.c. * The second edit is a typo (compare the address from the example output to the address in the explanation of that output).
@@ -37,7 +37,7 @@ Build a sample vulnerable program: | |||
```bash | |||
$ cd example | |||
$ make sf | |||
clang-sf -fsanitize=address -O1 main.c -c -o main.sf.o | |||
clang-sf -fsanitize=address -O1 demo.c -c -o main.sf.o |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is already present in another pull request you'd made. No need to add it here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops this and the other doc change is due to my own bad skill with Github PRs. I'll clean this up.
@@ -48,7 +48,7 @@ $ ./demo-sf 11 | |||
[SF], 1, 0x123, 0x456, 0, 0x789 | |||
r = 0 | |||
``` | |||
Here, the line `[SF], 1, 0x123, 0x456, 0, 0x52b519` means that SpecFuzz detected that the instruction | |||
Here, the line `[SF], 1, 0x123, 0x456, 0, 0x789` means that SpecFuzz detected that the instruction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
@@ -588,6 +588,8 @@ auto X86SpecFuzzPass::visitWrite(MachineInstr &MI, MachineBasicBlock &Parent) -> | |||
// Pushes are a special case as the address is always in RSP | |||
if (isPush(MI.getOpcode())) | |||
return visitPush(MI, Parent); | |||
if(MI.getOpcode() == X86::MFENCE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a cleaner way to do it. Just add MFENCE to X86SpecFuzzPass::isExplicitlySerializing
. In this case, MFENCE will be skipped completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I'll send an update later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you, please, also add a corresponding test to the test suite? See the tests/
directory for examples.
Before this change, the SpecFuzz pass would fail to compile code that used
MFENCEs because it is treated as a write instruction with no memory operands by
LLVM.
This patch skips instrumenting MFENCEs. In the future, it might make sense to
have SpecFuzz respond in some way to MFENCEs, but for now, skipping them is a
decent workaround.
Tested by using the test case here: #18, before the change it crashes, after the change it compiles