Skip to content

syscall: use O_SEARCH for held directory traversal on macOS - #1145

Open
padenot wants to merge 1 commit into
RsyncProject:masterfrom
padenot:o-search
Open

padenot wants to merge 1 commit into
RsyncProject:masterfrom
padenot:o-search

Conversation

@padenot

@padenot padenot commented Nov 3, 2026

Copy link
Copy Markdown

Since 3.5.0 the receiver resolves its destination one component at a time with held directory fds. Without O_PATH these are opened O_RDONLY|O_DIRECTORY, so on macOS every ancestor of the destination must be readable, not just searchable. A destination below a mode 0711 home, or a sandbox that denies listing $HOME, fails with change_dir#1.

We use rsync in the Firefox build system, and some of our developers use this rsync version, and not the built-in macOS version. Some developers sandbox their LLM agents with a little custom utility using Seatbelt/sandbox-exec, and rsync fails because this utility blocks read access in paths above the Firefox source tree, only leaving the tree and some select directories (caches, etc.) read/write.

This patch adds O_SEARCH|O_DIRECTORY where O_PATH is unavailable.

In terms of support, macOS 13+ and illumos check only search permission for it, so this fixes our use-case. Older macOS and NetBSD ignore it, so they keep the existing O_RDONLY|O_DIRECTORY behaviour.

We can now run the search-only tests on macOS 13+ instead of Linux only. I also added a comment to explain why 2 tests are seemingly failing in my local runs.

Comment thread syscall.c Resolved
Comment thread SECURITY.md Resolved
Since 3.5.0 the receiver resolves its destination one component at a
time with held directory fds.  Without O_PATH these are opened
O_RDONLY|O_DIRECTORY, so on macOS every ancestor of the destination must
be readable, not just searchable.  A destination below a mode 0711 home,
or a sandbox that denies listing $HOME, fails with change_dir#1.

Use O_SEARCH on macOS: from macOS 13 it needs only search permission,
and older kernels ignore it, keeping the O_RDONLY|O_DIRECTORY behaviour.
Not on illumos/Solaris, which checks search permission before
O_DIRECTORY, so probing a regular file fails with EACCES rather than the
ENOTDIR the resolvers expect.

Run the search-only tests on macOS 13+ and FreeBSD.  Their root runs
there skip for lack of setpriv, so mark them fleet_nonroot and add
targeted non-root steps to those CI jobs.
@padenot

padenot commented Nov 3, 2026

Copy link
Copy Markdown
Author

I retitled this because it's now narrower in scope.

@padenot padenot changed the title syscall: use O_SEARCH for held directory traversal syscall: use O_SEARCH for held directory traversal on macOS Nov 3, 2026
@padenot
padenot requested a review from steadytao November 3, 2026 12: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.

2 participants