Skip to content

Conversation

@cyphar
Copy link
Member

@cyphar cyphar commented Nov 12, 2025

Backport of #4985 (draft until merged).


In order to maintain compatibility with previous releases of runc (which
permitted dangling symlinks as path components by permitting
non-existent path components to be treated like real directories) we
have to first do SecureJoin to construct a target path that is
compatible with the old behaviour but has all dangling symlinks (or
other invalid paths like ".." components after non-existent directories)
removed.

This is effectively a more generic verison of commit 3f92552
("rootfs: re-allow dangling symlinks in mount targets") and will let us
remove the need for open-coding SecureJoin workarounds.

Signed-off-by: Aleksa Sarai [email protected]

@cyphar cyphar added the backport/1.4-pr A backport PR to release-1.4 label Nov 12, 2025
@cyphar cyphar added this to the 1.4.1 milestone Nov 12, 2025
@cyphar cyphar changed the title pathrs: add "hallucination" helpers for SecureJoin magic [1.4] pathrs: add "hallucination" helpers for SecureJoin magic Nov 12, 2025
@cyphar cyphar force-pushed the 1.4-hallucinated-paths branch from 277e846 to c03ae43 Compare November 26, 2025 03:53
@cyphar cyphar modified the milestones: 1.4.1, 1.4.0 Nov 26, 2025
@cyphar cyphar marked this pull request as ready for review November 26, 2025 04:04
cyphar and others added 6 commits November 26, 2025 21:05
These helpers will be needed for the compatibility code added in future
patches in this series, but because "internal/pathrs" is imported by
"libcontainer/utils" we need to move them so that we can avoid circular
dependencies.

Because the old functions were in a non-internal package it is possible
some downstreams use them, so add some wrappers but mark them as
deprecated.

Signed-off-by: Aleksa Sarai <[email protected]>
(cherry picked from commit 42a1e19)
Signed-off-by: Aleksa Sarai <[email protected]>
This probably should've been done as part of commit d40b343
("rootfs: switch to fd-based handling of mountpoint targets") but it
seems I missed them when doing the rest of the conversions.

This also lets us remove utils.WithProcfd entirely, as well as
pathrs.MkdirAllInRoot. Unfortunately, WithProcfd was exposed in the
externally-importable "libcontainer/utils" package and so we need to
have a deprecation notice to remove it in runc 1.5.

Signed-off-by: Aleksa Sarai <[email protected]>
(cherry picked from commit 9dbd37e)
Signed-off-by: Aleksa Sarai <[email protected]>
Now that MkdirAllInRoot has been removed, we can make MkdirAllInRootOpen
less wordy by renaming it to MkdirAllInRoot. This is a non-functional
change.

Signed-off-by: Aleksa Sarai <[email protected]>
(cherry picked from commit 20c5a8e)
Signed-off-by: Aleksa Sarai <[email protected]>
In order to maintain compatibility with previous releases of runc (which
permitted dangling symlinks as path components by permitting
non-existent path components to be treated like real directories) we
have to first do SecureJoin to construct a target path that is
compatible with the old behaviour but has all dangling symlinks (or
other invalid paths like ".." components after non-existent directories)
removed.

This is effectively a more generic verison of commit 3f92552
("rootfs: re-allow dangling symlinks in mount targets") and will let us
remove the need for open-coding SecureJoin workarounds.

Signed-off-by: Aleksa Sarai <[email protected]>
(cherry picked from commit cfb7432)
Signed-off-by: Aleksa Sarai <[email protected]>
While CreateInRoot supports hallucinating the target path, we do not use
it directly when constructing device inode targets because we need to
have different handling for mknod and bind-mounts.

The solution is to simply have a more generic MkdirAllParentInRoot
helper that MkdirAll's the parent directory of the target path and then
allows the caller to create the trailing component however they like.
(This can be used by CreateInRoot internally as well!)

Signed-off-by: Aleksa Sarai <[email protected]>
(cherry picked from commit 195e955)
Signed-off-by: Aleksa Sarai <[email protected]>
We intentionally broke this in commit d40b343 ("rootfs: switch to
fd-based handling of mountpoint targets") under the assumption that most
users do not need this feature. Sadly it turns out they do, and so
commit 3f92552 ("rootfs: re-allow dangling symlinks in mount
targets") added a hotfix to re-add this functionality.

This patch adds some much-needed tests for this behaviour, since it
seems we are going to need to keep this for compatibility reasons (at
least until runc v2...).

Co-developed-by: lifubang <[email protected]>
Signed-off-by: Aleksa Sarai <[email protected]>
(cherry picked from commit 15d7c21)
Signed-off-by: Aleksa Sarai <[email protected]>
@cyphar cyphar force-pushed the 1.4-hallucinated-paths branch from c03ae43 to 6a270e4 Compare November 26, 2025 10:05
Copy link
Member

@rata rata left a comment

Choose a reason for hiding this comment

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

LGTM. Seems like a clean backport of something that was already merged in main.

@rata rata merged commit 7d84a12 into opencontainers:release-1.4 Nov 27, 2025
37 checks passed
@cyphar cyphar deleted the 1.4-hallucinated-paths branch November 27, 2025 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/1.4-pr A backport PR to release-1.4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants