Issue 36856: faulthandler._stack_overflow doesn't work on x86-linux with KPTI enabled
Created on 2019-05-08 17:23 by xry111, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 13205 | merged | xry111, 2019-05-08 17:57 | |
| PR 13605 | merged | miss-islington, 2019-05-27 23:50 | |
| Messages (6) | |||
|---|---|---|---|
| msg341915 - (view) | Author: Xi Ruoyao (xry111) * | Date: 2019-05-08 17:23 | |
In faulthandler.c STACK_OVERFLOW_MAX_SIZE is defined to 100 * 1024 * 1024 (100MB). But recently KPTI has been applied to mitigate Meltdown (CVE-2017-5754) so the userspace stack pointer may be very close to 0xffffffff on Linux systems with 32-bit x86. For example, on my laptop it's sometimes 0xffffcc20. So the expression sp + STACK_OVERFLOW_MAX_SIZE overflows and becomes a very small number. That causes faulthandler._stack_overflow() to bail out after only one recursive call: Traceback (most recent call last): File "<string>", line 1, in <module> RuntimeError: unable to raise a stack overflow (allocated 4124 bytes on the stack, 1 recursive calls) |
|||
| msg341922 - (view) | Author: Pablo Galindo Salgado (pablogsal) * ![]() |
Date: 2019-05-08 18:16 | |
Are uintptr_t overflow/underflow semantics a defined behavior? |
|||
| msg341923 - (view) | Author: Xi Ruoyao (xry111) * | Date: 2019-05-08 18:19 | |
> Are uintptr_t overflow/underflow semantics a defined behavior? Yes. Unlike signed overflow, unsigned overflow is defined to be 2's complement. The problem is this overflow results a wrong stack pointer limit and breaks _stack_overflow. |
|||
| msg342209 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2019-05-11 17:13 | |
New changeset 6236c9823ef3e8e2229b0598d3d8189adf5e00f2 by Victor Stinner (Xi Ruoyao) in branch 'master': bpo-36856: Handle possible overflow in faulthandler_stack_overflow (GH-13205) https://github.com/python/cpython/commit/6236c9823ef3e8e2229b0598d3d8189adf5e00f2 |
|||
| msg343719 - (view) | Author: miss-islington (miss-islington) | Date: 2019-05-28 00:14 | |
New changeset 1062cf71faa14b90185cf159877083910df10f27 by Miss Islington (bot) in branch '3.7': bpo-36856: Handle possible overflow in faulthandler_stack_overflow (GH-13205) https://github.com/python/cpython/commit/1062cf71faa14b90185cf159877083910df10f27 |
|||
| msg343721 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2019-05-28 00:20 | |
Thanks Xi Ruoyao, I applied your fix to 3.7 and master branches. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:14 | admin | set | github: 81037 |
| 2019-05-28 00:20:17 | vstinner | set | status: open -> closed resolution: fixed messages: + msg343721 stage: patch review -> resolved |
| 2019-05-28 00:14:24 | miss-islington | set | nosy:
+ miss-islington messages: + msg343719 |
| 2019-05-27 23:50:13 | miss-islington | set | pull_requests: + pull_request13511 |
| 2019-05-11 17:13:26 | vstinner | set | messages: + msg342209 |
| 2019-05-08 18:19:13 | xry111 | set | messages: + msg341923 |
| 2019-05-08 18:16:16 | pablogsal | set | nosy:
+ pablogsal messages: + msg341922 |
| 2019-05-08 17:57:57 | xry111 | set | keywords:
+ patch stage: patch review pull_requests: + pull_request13116 |
| 2019-05-08 17:24:26 | SilentGhost | set | nosy:
+ vstinner |
| 2019-05-08 17:23:39 | xry111 | create | |
