hcc
hcc copied to clipboard
libmcwamp_hsa.so has an executable stack
libmcwamp_hsa.so is built with an executable stack:
readelf -l libmcwamp_hsa.so | grep GNU_STACK -A 1 GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 RWE 0x10
I think this is happening because mcwamp_hsa.cpp.o hsa a note.GNU-stack section that is marked executable. Is this being done intentionally? I haven't been able to figure out what is generating this section.
readelf -S lib/hsa/CMakeFiles/mcwamp_hsa.dir/mcwamp_hsa.cpp.o | grep note.GNU-stack -A 1 [29] .note.GNU-stack PROGBITS 0000000000000000 00280aaa 0000000000000000 0000000000000000 X 0 0 1
@AlexVlx @scchan @whchung Do any of you recall if we need to have an exec stack in mcwamp.o? I can try to add -noexecstack to our build of mcwamp.cpp and see if all still works.
@tstellar This just seems like the default (on ubuntu for ELF), unless we explicitly remove the exec stack from mcwamp.o. Do you have concerns with the exec stack being there?
From https://fedoraproject.org/wiki/Packaging_tricks#Executable_stack
rpmlint will complain if you generate code that permits stack execution, which is justified since this is rarely needed and is often used by attackers to exploit vulnerabilities.
@david-salinas As @FelixSchwarz mentioned we prefer not to ship executable stacks in Fedora, but I guess my question is less about libmcwamp_hsa.so having an executable stack and more about why does hcc compile objects with an executable stack by default. I don't think this is Ubuntu specific since it also happens on Fedora.
@tstellar sorry for the delay. So, I believe this is an artifact of default Clang behaviour. I'm trying to see if this can be disabled by default.
@tstellar so HCC will generate objects with an executable stack, because clang does this by default. This can be disabled with the linker option -Wl,-z,noexecstack when you invoke HCC. Our "clamp-link" respects any passed linker options (-Wl). Also, the dynamically linked shared library "libmcwamp_hsa.so" currently does still have this executable stack entry, but I'm uncertain if this poses a security issue.
I'm uncertain if this poses a security issue.
Regardless of the actual security impact it would be nice to have non-executable stacks wherever possible. :-)