Skip to content

coreutils: reduce 1 syscall when called via shebang & avoid race - #17019

Open
oech3 wants to merge 1 commit into
uutils:mainfrom
oech3:shargv0
Open

oech3 wants to merge 1 commit into
uutils:mainfrom
oech3:shargv0

Conversation

@oech3

@oech3 oech3 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor
  • replace open + read with 1 readlink when called via shebang (e.g. #!/usr/bin/env).
  • Fix wrong comment about SELinux.

Address shebang part of #15785 .

By the way, Ubuntu rust-coreutils is patched to panic when /proc is not mounted for AppArmor and they broke #!/usr/bin/env.

@oech3

oech3 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@julian-klode @varranvar Would you review this and check that if Ubuntu can drop the AppArmor patch?

@oech3

oech3 commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Symlink bypass is addressed at #16981 .

@oech3
oech3 marked this pull request as ready for review November 30, 2026 11:40
Comment thread src/common/validation.rs Resolved
Comment thread src/common/validation.rs Resolved
Comment thread src/common/validation.rs Resolved
Comment thread src/common/validation.rs Resolved
@sylvestre

Copy link
Copy Markdown
Contributor

thanks for looking into this!
The new current_exe() filter doesn't recognise the multicall the way main() does (see the inline comment), and there is no test for the shebang path yet.

@oech3
oech3 force-pushed the shargv0 branch 4 times, most recently from dd7d8d2 to 8ba5342 Compare November 30, 2026 22:54
@oech3
oech3 requested a review from sylvestre November 30, 2026 23:00
@oech3
oech3 force-pushed the shargv0 branch 2 times, most recently from 7816c59 to 4f30c37 Compare November 30, 2026 23:05
@oech3

oech3 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor Author

I'll drop last #! clause since it is useless compared with /proc/self/exe.
/proc/self/exe is not racy if hardlinks are owned by root while reading path to myself is not.

@oech3
oech3 force-pushed the shargv0 branch 4 times, most recently from 7f3b987 to e6472f8 Compare December 1, 2026 13:42
@oech3

oech3 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor Author

By the way, I want to make argv0 more unreliable after #17028 was merged.
I think we can support AppArmor's usecase as "side-effect" of useful sylink alias extension which improves compatibility with individual binaries.

@oech3
oech3 force-pushed the shargv0 branch 4 times, most recently from 517b062 to 3eaf3f1 Compare December 1, 2026 16:30

This branch has not been deployed

No deployments
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.

2 participants