[Bug c/104884] functions miss their 'ret' instruction (and fall through) in certain cases with '-O3' under x86-64

zamfofex at twdb dot moe gcc-bugzilla@gcc.gnu.org
Fri Mar 11 18:20:21 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104884

--- Comment #2 from zamfofex at twdb dot moe ---
Isn’t it dangerous to allow the control to accidentally leak out of a function
like that, though? If a function is written in a way that expects the compiler
to not allow the control to leak out of the function and it is compiled with
‘-O3’, then that can lead to code being executed in unexpected situations,
which feels like a fairly significant attack vector.

Imagine e.g. the code in the executable immediately after the function
definition contains some kind of secretive functionality, and the program is
being run as some kind of server. That could allow attackers to exploit that
compiler behavior in programs that use undefined behavior by accident.


More information about the Gcc-bugs mailing list