[GHC] #10155: [PATCH] Possibly incorrect stack pointer usage in StgRun() on x86_64

#10155: [PATCH] Possibly incorrect stack pointer usage in StgRun() on x86_64 -------------------------------------+------------------------------------- Reporter: stengel | Owner: simonmar Type: bug | Status: new Priority: normal | Milestone: Component: Runtime | Version: 7.8.1 System | Operating System: Unknown/Multiple Keywords: | Type of failure: Other Architecture: x86_64 | Blocked By: (amd64) | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- The STG_RETURN code from StgCRun.c is incorrect for x86_64 variants where the ABI doesn't impose a mandatory red zone for the stack, like on Windows or Xen/HaLVM. The current implementation restores the stack pointer first, which effectively marks the area with the saved registers as reusable. Later, the CPU registers are restored from this "free" area. This ordering happens to work by accident on operating systems that strictly adhere to the System V ABI, because any interrupt/signal delivery is guaranteed to leave the first 128 bytes past the stack pointer untouched (red zone). On other systems this might result in corrupted CPU registers if an interruption happens just after restoring the stack pointer. The red zone is usually only used by small leaf functions to avoid updates to the stack pointer and exploiting it doesn't give us any advantage in this case. The attached patch reorders the register access, so that the stack pointer is restored last. It's also shorter by one instruction. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10155 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10155: [PATCH] Possibly incorrect stack pointer usage in StgRun() on x86_64 -------------------------------------+------------------------------------- Reporter: stengel | Owner: simonmar Type: bug | Status: patch Priority: high | Milestone: 7.10.1 Component: Runtime System | Version: 7.8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Other | (amd64) Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * priority: normal => high * status: new => patch * milestone: => 7.10.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10155#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10155: [PATCH] Possibly incorrect stack pointer usage in StgRun() on x86_64 -------------------------------------+------------------------------------- Reporter: stengel | Owner: Type: bug | thoughtpolice Priority: high | Status: patch Component: Runtime System | Milestone: 7.12.1 Resolution: | Version: 7.8.1 Operating System: Unknown/Multiple | Keywords: Type of failure: Other | Architecture: x86_64 Blocked By: | (amd64) Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by simonmar): * owner: simonmar => thoughtpolice Comment: Looks good to me - @thoughtpolice could you put it in your next validate run? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10155#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10155: [PATCH] Possibly incorrect stack pointer usage in StgRun() on x86_64
-------------------------------------+-------------------------------------
Reporter: stengel | Owner:
| thoughtpolice
Type: bug | Status: patch
Priority: high | Milestone: 7.12.1
Component: Runtime System | Version: 7.8.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: x86_64
| (amd64)
Type of failure: Other | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#10155: [PATCH] Possibly incorrect stack pointer usage in StgRun() on x86_64 -------------------------------------+------------------------------------- Reporter: stengel | Owner: | thoughtpolice Type: bug | Status: closed Priority: high | Milestone: 7.12.1 Component: Runtime System | Version: 7.8.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 | (amd64) Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10155#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC