Skip to content

rm: gentoo sandbox violation when emerging certain python packages #7002

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

Closed
elde-n opened this issue Dec 26, 2024 · 7 comments · Fixed by #7010
Closed

rm: gentoo sandbox violation when emerging certain python packages #7002

elde-n opened this issue Dec 26, 2024 · 7 comments · Fixed by #7010

Comments

@elde-n
Copy link
Contributor

elde-n commented Dec 26, 2024

When replacing GNU rm with uutils-rm (cp /usr/bin/uu-rm /usr/bin/rm) I get an error when emerging certain python packages.
However when replacing GNU rm with busybox-rm everything is fine.

sandbox.log

VERSION 1.0
FORMAT: F - Function called
FORMAT: S - Access Status
FORMAT: P - Path as passed to function
FORMAT: A - Absolute Path (not canonical)
FORMAT: R - Canonical Path
FORMAT: C - Command Line

F: open_wr
S: deny
P: /var/tmp/portage/dev-python/pip-24.3.1-r2/work/pip-24.3.1-python3_12/install//usr/bin/python3.12
A: /var/tmp/portage/dev-python/pip-24.3.1-r2/work/pip-24.3.1-python3_12/install/usr/bin/python3.12
R: /usr/bin/python3.12
C: rm /var/tmp/portage/dev-python/pip-24.3.1-r2/work/pip-24.3.1-python3_12/install//usr/bin/python3.12 /var/tmp/portage/dev-python/pip-24.3.1-r2/work/pip-24.3.1-python3_12/install//usr/bin/python3 /var/tmp/portage/dev-python/pip-24.3.1-r2/work/pip-24.3.1-python3_12/install//usr/bin/python /var/tmp/portage/dev-python/pip-24.3.1-r2/work/pip
-24.3.1-python3_12/install//usr/bin/pyvenv.cfg
@sylvestre
Copy link
Contributor

please provide some steps to reproduce.
thanks

@elde-n
Copy link
Contributor Author

elde-n commented Dec 26, 2024

  1. su
  2. echo "sys-apps/uutils-coreutils ~amd64" >> /etc/portage/package.accept_keywords/uutils-coreutils
  3. emerge "=sys-apps/uutils-coreutils-0.0.28"
  4. rm /usr/bin/rm
  5. ln -s /usr/bin/uu-coreutils /usr/bin/rm
  6. emerge dev-python/pip

@sylvestre
Copy link
Contributor

Sorry, i meant some simple commands with rm and the other steps that triggered the issue
not something that requires installing Gentoo.

@elde-n
Copy link
Contributor Author

elde-n commented Dec 28, 2024

looking at strace you can see that uu-rm calls open("path", O_RDWR|O_LARGEFILE|O_CLOEXEC), while the gnu rm/busybox rm don't, the open_wr is what triggers the portage sandbox

@sylvestre
Copy link
Contributor

Please provide steps to reproduce :)
it is way too hard to fix otherwise

@elde-n
Copy link
Contributor Author

elde-n commented Dec 28, 2024

  1. run this script
touch test.txt
strace -o gnu.log /usr/bin/rm test.txt

touch test.txt
strace -o uu.log /usr/bin/uu-rm test.txt

touch test.txt
strace -o busybox.log /usr/bin/busybox rm test.txt
  1. compare the files

std::fs::remove_file() itself doesn't call open, you're using std::fs::OpenOptions which calls open
busybox rm and gnu rm use access/faccessat2 to check for write permissions

@sylvestre
Copy link
Contributor

how do i setup the sandbox?

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 a pull request may close this issue.

2 participants