Skip to content

chmod: use the libc fchmodat symbol for recursive mode changes - #14121

Merged
sylvestre merged 2 commits into
uutils:mainfrom
sylvestre:preload
Aug 25, 2026
Merged

chmod: use the libc fchmodat symbol for recursive mode changes#14121
sylvestre merged 2 commits into
uutils:mainfrom
sylvestre:preload

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

Fixes #14028

Copilot AI lite review requested due to automatic review settings August 24, 2026 17:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/tail/pid-pipe (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/tail-n0f (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/cut/bounded-memory (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/seq/seq-epipe is now passing!

@codspeed-hq

codspeed-hq Bot commented Aug 24, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 3.22%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 4 improved benchmarks
✅ 353 untouched benchmarks
⏩ 50 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation du_summarize_balanced_tree[(5, 4, 10)] 16.5 ms 15.9 ms +3.42%
Simulation cksum_sysv 68.4 ms 66.2 ms +3.32%
Simulation cksum_crc32b 39.7 ms 38.5 ms +3.11%
Simulation cksum_multiple_files 61.5 ms 59.7 ms +3.01%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing sylvestre:preload (e3e5876) with main (ebb9ab1)

Open in CodSpeed

Footnotes

  1. 50 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

The raw syscall(SYS_fchmodat2, ...) in DirFd::chmod_at bypassed LD_PRELOAD
tools (fakeroot, fakechroot, pseudo), so a recursive mode change landed on
disk but their bookkeeping never saw it, silently and with exit status 0.
Try libc fchmodat() first and keep the raw syscall as a fallback for the
NoFollow case libc declines; glibc issues fchmodat2 from there anyway.

Add util/check-libc-interposition.sh, which runs chown -R and chmod -R
under fakeroot and compares what fakeroot reports afterwards.

Fixes uutils#14028
Copilot AI review requested due to automatic review settings August 24, 2026 21:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sylvestre

Copy link
Copy Markdown
Contributor Author

@nadzyah
@julian-klode
wdyt ? :)
thanks

@sylvestre

Copy link
Copy Markdown
Contributor Author

@codspeedbot explain why this is faster

@sylvestre
sylvestre merged commit e006771 into uutils:main Aug 25, 2026
170 checks passed
@nadzyah

nadzyah commented Aug 25, 2026

Copy link
Copy Markdown

@sylvestre hey! Sorry, I didn't review it this quickly as I wanted to test the change

I've verified that it fixes the issue. I reverted safe_traversal.rs to the base commit and ran the new check. It fails (fakeroot reports '775', expected '2751') and passes with your change, so the regression test really does catch the bug. I also checked a deeper tree under fakeroot (every level is recorded, setgid included) and compared against GNU chmod for -R 755, -R 2751, -R 1777, -R 4755, -R u+s,g+s,o+t, -R a+X and -R -L/-H/-P. All modes match!

Thank you for the fix!

@sylvestre
sylvestre deleted the preload branch August 25, 2026 15:10
@sylvestre

Copy link
Copy Markdown
Contributor Author

@nadzyah np and thanks for testing !
btw maybe fakeroot should be less used ;)

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.

chmod -R: raw fchmodat2 syscall bypasses libc, breaking LD_PRELOAD tools

3 participants