Skip to content

0.18.3 --- a directory handle names a directory and does not read one - #42

Merged
Sunrisepeak merged 1 commit into
mainfrom
openkal-linux-0.18.3
Oct 29, 2026
Merged

Sunrisepeak merged 1 commit into
mainfrom
openkal-linux-0.18.3

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

A kal_dir is opened with O_PATH | O_DIRECTORY | O_CLOEXEC: the two preopens and kal_fs_open_dir. Resolving beneath a handle, starting a program in it and describing it need no read right; kal_fs_list_begin opens a readable descriptor of its own when it lists.

Why. mcpp-community/mcpp#857: in the Android app sandbox (run-as, SELinux runas_app) every program mcpp starts failed with "not found". A static strace of the failing build (mcpp#861, run 40908273317) shows one failing call, before any process is created:

openat(AT_FDCWD, "/", O_RDONLY|O_CLOEXEC|O_DIRECTORY) = -1 EACCES (Permission denied)

The domain may search / but not read it, so the root preopen did not exist and every name resolved beneath it failed. Each step of the start itself (openat O_PATH, readlink, fstatat, execveat AT_EMPTY_PATH, execve) succeeds there when called directly (run 40904947962).

Test. tests/search_only_base.cpp: a directory of mode 0111 is a base — a file beneath it opens and reads, a program starts in it — and listing it is refused (for an unprivileged user).

Also: the comment on the ENOSYS fallback said a start learns it from an earlier one; the started image is a clone copy without shared memory, so each start that meets ENOSYS falls back on its own. The comment now says so.

Co-authored-by: speak-agent [email protected]

Every kal_dir, the two preopens included, is opened with O_PATH: resolving
beneath it, starting a program in it and describing it read nothing, and
listing already opens a readable descriptor of its own. Measured on Android 14
under run-as (SELinux runas_app, mcpp#857): the preopen of / failed with EACCES,
and every program started by absolute name was reported as not found.

The comment on the ENOSYS fallback now states what the code does: each start
that meets ENOSYS falls back in the started image, and no start learns it from
another.

Co-authored-by: speak-agent <[email protected]>
@Sunrisepeak
Sunrisepeak merged commit cde4abb into main Oct 29, 2026
2 checks passed
@Sunrisepeak
Sunrisepeak deleted the openkal-linux-0.18.3 branch October 29, 2026 16:41
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.

1 participant