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 Linux's unshare(2) abilities to further limit what compilers can do #439

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thiagomacieira
Copy link
Contributor

It's the same principle as containers. We limit:

  • CLONE_NEWIPC (SysV IPC): accessing IPC in the system
  • CLONE_NEWNET (networking): network access (only loopback allowed)
  • CLONE_NEWNS (mount namespace): complements chroot
  • CLONE_NEWPID (PIDs): no ptrace(2) or kill(2) any other processes
  • CLONE_NEWUSER (users): no other processes share UID
  • CLONE_NEWUTS (UTS)

As a side-effect of CLONE_NEWPID, when run, the compiler will see itself
as PID 1.

It's the same principle as containers. We limit:
- CLONE_NEWIPC (SysV IPC): accessing IPC in the system
- CLONE_NEWNET (networking): network access (only loopback allowed)
- CLONE_NEWNS (mount namespace): complements chroot
- CLONE_NEWPID (PIDs): no ptrace(2) or kill(2) any other processes
- CLONE_NEWUSER (users): no other processes share UID
- CLONE_NEWUTS (UTS)

As a side-effect of CLONE_NEWPID, when run, the compiler will see itself
as PID 1.
@thiagomacieira
Copy link
Contributor Author

Can't reproduce the failure on my openSUSE Tumbleweed.

@thiagomacieira
Copy link
Contributor Author

ping. Please advise what to do.

@llunak
Copy link
Contributor

llunak commented Jun 2, 2019

I can reproduce that on openSUSE 15.0/1 . Both Clang and GCC get stuck in read(), presumably trying to read stdin data that never comes, because the local cpp has failed. I don't understand that, because stdin should get EOF, and the flag that triggers this is CLONE_NEWPID.

@HenryMiller1
Copy link
Collaborator

I'd like to have this (ideally on more than linux), but the hang is concerning. I added help wanted, it is probably a hard task to figure out why the hang happens on some system. If we can figure out why it hangs in some cases we can figure out what to do.

@HenryMiller1
Copy link
Collaborator

On thing that comes to mind is perhaps old versions are buggy. If we can figure out where the bug was fixed we can disable this. If the bug is old enough we can document those systems as unsupported. It is worth rebasing with the latest where we have different CI systems.

@deriamis
Copy link

I'm going to take a look at this in the coming couple of weeks and see if I can figure out what's going on here.

@deriamis deriamis self-assigned this Jun 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants