This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Refactor thread-step-out-ret-addr-check test to use .data instead of stack variable
AbandonedPublic

Authored by mossberg on Dec 20 2019, 3:11 PM.

Details

Summary

Original diff: D71372
Related diff: D71784

D71784 shows that we cannot assume the stack is not executable across platforms. Refactor the test to use a variable from the .data section which should be guaranteed non-executable.

I would appreciate guidance regarding the var@GOTPCREL(%rip). Directly referencing var would not assemble on my darwin machine due to an error about absolute addressing, and I used this to workaround it. I'm not sure if it's even portable to other platforms?

@jankratochvil Would you be able to test this on a Fedora machine, please?

Diff Detail

Event Timeline

mossberg created this revision.Dec 20 2019, 3:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 20 2019, 3:11 PM

I don't really understand what's going on, but it seems that the lack of the .note.GNU-stack section causes the data section to be executable too (at least on my machine, anyway). Which means that using the data address will not help. :( I'm cc'ing some people who know more about dynamic linkers to see if anyone can explain this behavior...

One sure way to get a non-executable memory address would be to allocate something on the heap (in the C file), but I think @jankratochvil's approach of adding the .note.GNU-stack is simpler, and so far it seems that it works everywhere. The section directive will trip up the non-linux assemblers though, so it needs to be #ifdef __linux__ (afaict #ifdefs work just fine in asm files when invoking the processing through clang)...

lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
18

This should be 0x08, or you'll should push one more value to stack in asm_main.

jankratochvil requested changes to this revision.Dec 21 2019, 1:45 AM

My testing matches the @labath's one. I have updated D71784.

This revision now requires changes to proceed.Dec 21 2019, 1:46 AM
mossberg abandoned this revision.Dec 21 2019, 9:49 AM

Thanks all for testing this! I had no idea it was this hard to get a non-executable section :)

Superseded by D71784