OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 10:07 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Does anyone need executable stack?
PostPosted: Wed Mar 17, 2021 8:14 am 
Offline
Member
Member

Joined: Thu May 17, 2007 1:27 pm
Posts: 999
Velko wrote:
Back to the topic about stacks. I'm not getting why would one want to inject code into stack for returns from signal handler. Can not that be handled by having a bit of prologue and epilogue code in libc / glue library? Instead of registering the address of signal handler directly with kernel, store the signal handler callback in userspace variable and register the beginning of the prologue code instead.

Yes, that can indeed be done and it's the VDSO code that nullplan was referring to (and on Linux, sigaction() has a SA_RESTORER flag for this purpose). The stack-based solution is done by Linux for uncooperative libcs (which were presumably used at some point in the past).

_________________
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].


Top
 Profile  
 
 Post subject: Re: Does anyone need executable stack?
PostPosted: Wed Mar 17, 2021 12:00 pm 
Online
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
Korona wrote:
The stack-based solution is done by Linux for uncooperative libcs (which were presumably used at some point in the past).
Was done. Nowadays the code exists only to mark the stack frame (apparently, GDB depends on it). The old trampoline is older than the VDSO, which is what is now used for uncooperative libcs. Indeed, not using SA_RESTORER could be beneficial, as the VDSO trampolines also get the exception handler frame attached to it that contains all the data on how to restore the higher frames.

_________________
Carpe diem!


Top
 Profile  
 
 Post subject: Re: Does anyone need executable stack?
PostPosted: Wed Mar 17, 2021 1:24 pm 
Offline
Member
Member

Joined: Thu May 17, 2007 1:27 pm
Posts: 999
You can also add the exception handling annotations to your libc (via CFI pseudo instructions). We do that to get stack traces across exception stacks in the kernel.

_________________
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 28 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group