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

Don't return to parent after fork #886

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

bjorn3
Copy link
Collaborator

@bjorn3 bjorn3 commented Oct 21, 2024

This can cause closed files to be closed again, which will panic and is a violation of IO safety.

@bjorn3
Copy link
Collaborator Author

bjorn3 commented Oct 21, 2024

Added a CI fix. See the commit message.

@squell
Copy link
Member

squell commented Oct 21, 2024

Is it possible to write a regression test for this?

@bjorn3
Copy link
Collaborator Author

bjorn3 commented Oct 21, 2024

If I recall correctly the original case where I found the panic is as follows:

  • su is missing setuid.
  • PAM is configured to unconditionally allows the user to authenticate as itself even when the program that runs PAM is not doesn't have euid set to 0.
  • The user runs su $(whoami) when not root.
  • Su considers the user authenticated and attempts to setuid and fails.

On Linux PAM will ask the user to authenticate even when the user wants to run su to become itself. On FreeBSD PAM will allow su to be used without authentication when the target is the same as the calling user. I'm not sure how to configure Linux PAM to get the FreeBSD behavior in a test.

@bjorn3 bjorn3 force-pushed the no_fork_return branch 2 times, most recently from 2b2bb1b to c9b5a80 Compare October 21, 2024 15:58
@squell
Copy link
Member

squell commented Oct 21, 2024

It's OK to make an issue for this, so we can track the project. :)

This can cause closed files to be closed again, which will panic and is
a violation of IO safety.
This makes it clearer that exec_monitor can only return when there is an
error.
@squell squell merged commit 0107ff2 into trifectatechfoundation:main Nov 25, 2024
13 checks passed
@bjorn3 bjorn3 deleted the no_fork_return branch November 25, 2024 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PAM behaviour differs between Linux/FreeBSD, causing fork-unsafety on BSD
2 participants