| #
8efa35fe
|
| 08-Jul-2025 |
Timothy Pearson <tpearson@raptorengineering.com> |
libc/powerpc64: Fix swapcontext(3)
On PowerPC platforms a valid link to the Table of Contents (TOC) is required for PLT lookups to function. This TOC pointer is stored in a dedicated register, and
libc/powerpc64: Fix swapcontext(3)
On PowerPC platforms a valid link to the Table of Contents (TOC) is required for PLT lookups to function. This TOC pointer is stored in a dedicated register, and is used along with the stack pointer by both C prologue and PLT lookup code.
When calling swapcontext() with uc_link != NULL, a PLT lookup to setcontext(3) is attempted from within the _ctx_done context. The exiting process has usually trashed both r1 and r2 at this point, leading to a crash within the PLT lookup before setcontext(2) is reached to restore the linked context.
Save and restore r2 as in a regular function. This ensures the subsequent PLT lookup to setcontext(3) succeeds.
Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com>
MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/1759
show more ...
|
| #
8efa35fe
|
| 08-Jul-2025 |
Timothy Pearson <tpearson@raptorengineering.com> |
libc/powerpc64: Fix swapcontext(3)
On PowerPC platforms a valid link to the Table of Contents (TOC) is required for PLT lookups to function. This TOC pointer is stored in a dedicated register, and
libc/powerpc64: Fix swapcontext(3)
On PowerPC platforms a valid link to the Table of Contents (TOC) is required for PLT lookups to function. This TOC pointer is stored in a dedicated register, and is used along with the stack pointer by both C prologue and PLT lookup code.
When calling swapcontext() with uc_link != NULL, a PLT lookup to setcontext(3) is attempted from within the _ctx_done context. The exiting process has usually trashed both r1 and r2 at this point, leading to a crash within the PLT lookup before setcontext(2) is reached to restore the linked context.
Save and restore r2 as in a regular function. This ensures the subsequent PLT lookup to setcontext(3) succeeds.
Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com>
MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/1759
show more ...
|
| #
8efa35fe
|
| 08-Jul-2025 |
Timothy Pearson <tpearson@raptorengineering.com> |
libc/powerpc64: Fix swapcontext(3)
On PowerPC platforms a valid link to the Table of Contents (TOC) is required for PLT lookups to function. This TOC pointer is stored in a dedicated register, and
libc/powerpc64: Fix swapcontext(3)
On PowerPC platforms a valid link to the Table of Contents (TOC) is required for PLT lookups to function. This TOC pointer is stored in a dedicated register, and is used along with the stack pointer by both C prologue and PLT lookup code.
When calling swapcontext() with uc_link != NULL, a PLT lookup to setcontext(3) is attempted from within the _ctx_done context. The exiting process has usually trashed both r1 and r2 at this point, leading to a crash within the PLT lookup before setcontext(2) is reached to restore the linked context.
Save and restore r2 as in a regular function. This ensures the subsequent PLT lookup to setcontext(3) succeeds.
Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com>
MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/1759
show more ...
|