For a Linux ABI process, namei() resolves a path first under the ABI
root (compat.linux.emul_path) and, if that fails, restarts the walk
of the original path from the native root. Since 459ac3044b51 an
absolute symlink target found during the ABI pass stays under the
ABI root, so self-contained Linux userlands resolve their own
symlinks correctly (PR 289739); but when the target names a file
that exists only in the native namespace, the walk fails and the
restart cannot recover: it re-walks the original path, whose
ABI-visible prefix (the symlink itself) does not exist natively.
Casualties are the absolute symlinks planted under the emulator root
to integrate the host into the Linux namespace -- among them
linux-rl9-fontconfig's /compat/linux/etc/fonts ->
/usr/local/etc/fonts (Linux fontconfig cannot load its
configuration, degrading font matching to arbitrary results) and
similar links from linux-rl9-alsa-lib and linux-rl9-ca-certificates
- and linprocfs' /proc/<pid>/exe, whose target is a host path:
following it fails for any Linux binary whose text lives outside the
emulator root (Chromium-based browsers execve /proc/self/exe to
spawn helpers), unless procfs(5) mounted at the native /proc masks
the failure.
Give absolute symlink targets the same overlay treatment original
paths receive: remember the expansion produced while following an
absolute symlink during the ABI pass and, when that pass fails with
ENOENT, retry the saved expansion from the native root before
falling back to the original path. Lookups that succeed under the
ABI root are unaffected, preserving 459ac3044b51; lockless lookups
are unaffected because cache_fplookup_symlink() already aborts to
the locked path for absolute symlinks whenever an ABI root is
active.
Add tests exercising the decision table: a target under the ABI root
wins over an identically named native file (PR 289739), native-only
targets fall back (PR 297426) including through a mid-path directory
symlink (the fontconfig shape), and the plain no-symlink native
fallback is unchanged.
PR: 297426
Fixes: 459ac3044b51 ("namei: Preserve ABI root for absolute symlinks before fallback")
MFC after: 1 month