Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use an alternate stack for signal handling #1847

Merged
merged 2 commits into from
Jan 14, 2022

Conversation

sporksmith
Copy link
Contributor

@sporksmith sporksmith commented Jan 11, 2022

Configure the shim's signal handlers (which are only used in preload mode) to use an alternate stack via sigaltstack. Experimentally this appears to fix the stack corruption observed in #1549.

In preload mode, also prevent managed calls to sigaltstack from overwriting our configuration. Eventually this should be implemented more faithfully, but this should be good enough at least until we're to the point of being able to invoke signal handlers configured by the managed process.

This is "milestone 1" of #1851

@github-actions github-actions bot added the Component: Libraries Support functions like LD_PRELOAD and logging label Jan 11, 2022
@sporksmith sporksmith added this to the Support for Signals milestone Jan 11, 2022
@github-actions github-actions bot added Component: Main Composing the core Shadow executable Component: Testing Unit and integration tests and frameworks labels Jan 11, 2022
@github-actions github-actions bot removed the Component: Testing Unit and integration tests and frameworks label Jan 14, 2022
@sporksmith sporksmith marked this pull request as ready for review January 14, 2022 16:43
Copy link
Contributor

@stevenengler stevenengler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! I verified that #1549 works for me now with the latest go version.

src/lib/shim/shim_tls.c Show resolved Hide resolved
This prevents managed calls to sigaltstack from interfering with the
shim's own configured sigaltstack.

The current fakery should be good enough until if and when a managed
program's signal handler is invoked. preload mode is already broken in
that case, though.

Once signal handlers in preload mode are working, we probably ought to
emulate this more faithfuly, since it may be difficult to debug if the
program goes wrong because *our* altstack wasn't big enough, or it
somehow detected it wasn't running on the configured stack etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Libraries Support functions like LD_PRELOAD and logging Component: Main Composing the core Shadow executable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants