[PATCH] D20346: [stack-protection] Add support for MSVC buffer security check

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 1 08:47:43 PDT 2016


rnk added a comment.

I looked into x64 a bit more, and this example shows that we need to do a similar upgrade from `__C_specific_handler` to `__GSHandlerCheck_SEH`:

  extern "C" void *memset(void*, int, int);
  int example(int offset, int index) {
    char buffer[10];
    __try {
      memset(buffer, 0xCC, index);
    } __except(1) {
    }
    return buffer[index];
  }

Looking at this example, I agree with David we should do this EH personality function upgrade in the backend if we decide to protect the stack. It just so happens that for 32-bit, MSVC always protects the stack when SEH is used, which is why I thought we should pick _except_handler4 in the frontend. We should also look at C++ EH, I forget what that does.

Anyway, I would have stack protector bail out on functions with funclet EH personalities for now (use `isFuncletEHPersonality` the way WinEHPrepare.cpp does). We can deal with the personality function upgrade later, and land this once we're sure this doesn't break EH.  We should also add the XOR with RSP/EBP/ESP as a followup.


http://reviews.llvm.org/D20346





More information about the llvm-commits mailing list