dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.2k stars 4.72k forks source link

[x86/Linux] Reenable stack protector #7133

Closed parjong closed 4 years ago

parjong commented 7 years ago

The current implementation of unwindLazyStack failed to recognize the following stack protection code (inserted by clang):

   0xf773af4c <SystemNative::_GetModuleFileName()+2284>:        mov    %gs:0x14,%ecx
   0xf773af53 <SystemNative::_GetModuleFileName()+2291>:        cmp    0x1b0(%esp),%ecx
   0xf773af5a <SystemNative::_GetModuleFileName()+2298>:        mov    %eax,0x14(%esp)
   0xf773af5e <SystemNative::_GetModuleFileName()+2302>:        jne    0xf773af86 <SystemNative::_GetModuleFileName()+2342>
...
   0xf773af86 <SystemNative::_GetModuleFileName()+2342>:        mov    0x88(%esp),%ebx
   0xf773af8d <SystemNative::_GetModuleFileName()+2349>:        call   0xf6c31ae0 <__stack_chk_fail@plt>

unwindLazyStack raises the following assert failure at mov %gs:0x14,%ecx:

Assert failure(PID 3233 [0x00000ca1], Thread: 3233 [0x0ca1]): !"Bad opcode"
    File: /home/parjong/projects/dotnet/coreclr/src/vm/i386/gmsx86.cpp Line: 1240
    Image: /root/dotnet-test/overlay/20161213/101106/corerun
parjong commented 7 years ago

As a workaround, dotnet/coreclr#8609 turns off stack protection.