Indirect Calling of Nested Functions on GCC Without Executable Stack

(uecker.codeberg.page)

24 points | by uecker 1 hour ago

4 comments

  • Dwedit 19 minutes ago
    What do you need the executable stack for? You call using a function pointer, there's no executable read/write memory involved in using a function pointer.
    • tom_ 11 minutes ago
      Nested functions may require a context pointer of some kind, which the caller can't supply. One way of doing this: create a thunk on the stack that provides the context pointer, and use that address as the pointer to the nested function.

      But now the stack needs to be executable.

    • dingaling911 3 minutes ago
      nested functions are like closures. you close over the stack of the caller.
  • mananaysiempre 36 minutes ago
    Related: previous article in the series, https://news.ycombinator.com/item?id=49308685 (103 points, 47 comments)
  • inigyou 41 minutes ago
    Self-modifying code is cool. It's a shame we had to disable it for security.
  • gue5t 27 minutes ago
    At first, I was annoyed by having to read AT&T syntax. Then I was disoriented by realizing the next snippet was in AT&T syntax without the '%' sigil for registers. But the technique is cool.