Repository navigation
libct: don't strip rootfs prefix from mount destinations - #5556
Conversation
422bcf1 to
8c1d9e5
Compare
93cd7e8 to
dc314eb
Compare
| if config.Rootfs != "/" && pathrs.IsLexicallyInRoot(config.Rootfs, filepath.Clean(m.Destination)) { | ||
| return fmt.Errorf("mount %+v: destination path prefixed with rootfs is **deprecated** and will be removed in runc 1.8, stripping the prefix", m) | ||
| } |
There was a problem hiding this comment.
We should kill this behaviour but I'm not really sure what we should do about it in the long term -- ideally we would treat it as a subpath but that will break things in other ways. Do we really want these paths to become cursed in runc 1.8?
Maybe we'll need to reconsider the idea of having annotations that indicate "enable the non-insane behaviour"? Idk.
(Also the , stripping the prefix feels like it should be -- stripping the prefix or ; stripping the prefix to indicate the action a little better.)
There was a problem hiding this comment.
Do we really want these paths to become cursed in runc 1.8?
No, I think in 1.8 we'll just remove the code which strips host path prefix (as well as this check). Sorry the comment says otherwise; this is now fixed. I've also fixed the warning message.
OR, we can just remove the host path stripping and add a CHANGELOG entry for it.
There was a problem hiding this comment.
I'd not go the annotation route. I'd either deprecate or remove it.
Commits 1f1e91b and 2192670 (PR 2917) added a check that a mount destination is absolute (as the runtime spec required back then) to both libcontainer/specconv and libcontainer/configs/validate. This broke Moby, which used relative destinations for swarm configs (issue 2928), so commit b31a934 (PR 3004) turned both errors into warnings, with TODOs to make them errors again in a future release. As a result, runc prints two warnings for the same relative mount destination, for example: level=warning msg="mount destination tmp/bind is not absolute. Support for non-absolute mount destinations will be removed in a future release." level=warning msg=configuration error="mount &{... Destination:tmp/bind ...}: relative destination path is **deprecated**, using it as relative to /" Later, the runtime spec was amended to allow relative mount destinations on Linux, treating them as relative to "/" (see opencontainers/runtime-spec PR 1225), and commit b17c6f2 (PR 4013) updated the validator accordingly, removing the TODO and changing the warning text. The specconv part was left as is, still having the stale TODO and the "will be removed" text. Remove the warning from specconv altogether, as the one from the validator is sufficient (and is also seen by libcontainer users who do not use specconv). Fixes: b31a934 ("libcontainer: relax validation for absolute paths") Fixes: b17c6f2 ("validator: Relax warning for not abs mount dst path") Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
474a988 to
9199eeb
Compare
kolyshkin
left a comment
There was a problem hiding this comment.
So, we either have to have a bunch of ugly TODOs added, and a warning that will go away, or be bold and brave and just implement those TODOs now (i.e remove host path prefix stripping).
crun never supported host path prefixed destinations and no one ever complained. I dunno
rata
left a comment
There was a problem hiding this comment.
Kubernetes users can't rely on this either, as they don't know where the rootfs will be located. With all the checks that you've done @kolyshkin , I'm fine with removing it and having the rc release be tested in several projects.
I wonder if we have to revert, if it might be simpler for us to disable the code but keep it for one release. Then, we can revert easily if needed or we can remove it after the next release.
|
@rata agreed; let's just remove this and release rc.2 with this so we can catch this early. As a side note, I'd like to cut rc.2 from the main branch, and then create release-1.6 branch from rc.2 (not rc.1) -- to avoid porting every PR merged to main after rc.1 release to release-1.6. |
For legacy reasons (see commit 087caf6), runc accepts a mount destination prefixed with the container rootfs path, and strips the prefix. This is not described by the runtime spec, which says the destination is a path inside the container, and is not supported by other runtimes (e.g. crun). It is also ambiguous, as such a path may legitimately exist inside the container. Remove the prefix stripping, so such a destination is used as is, i.e. as a path inside the container. Most of the stripping was done by hallucinateUnsafePath, used by pathrs.MkdirAllInRoot and friends, so device node paths are no longer stripped either. Add an integration test. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
9199eeb to
2096461
Compare
I tried implementing that, alas it's not as easy as say a bunch of
and the result would look ugly and (I guess) some linters will say something about dead code etc. So I think what is here right now is the optimal way. If anything, we can git revert (it's not that we change this code frequently). WDYT @rata? |
|
@kolyshkin yeap, sounds good! The disable was useful if this will ship in April to users, as a revert might be hard. If we ship it now, this seems the best path for me too :) |
e997894
For legacy reasons (see commit 087caf6, from the times when Docker used libcontainer directly), runc accepts a mount destination prefixed with the container rootfs path, and strips the prefix. This is not described by the runtime spec (which says the destination is a path inside the container), is not supported by other runtimes (e.g. crun), and is ambiguous, as such a path may legitimately exist inside the container.
I looked at the current code of moby, containerd (CRI), CRI-O, podman, buildah, buildkit, nerdctl, nomad, and garden (guardian), and none of them rely on this.
Remove it, so such a destination is used as is, i.e. as a path inside the container. Most of the stripping was done by
hallucinateUnsafePath(used bypathrs.MkdirAllInRootand friends), so device node paths are no longer stripped either. Add an integration test.While at it, remove the duplicate relative mount destination warning from specconv, together with the stale TODO saying it is to be changed to an error (the runtime spec now allows relative mount destinations on Linux, see opencontainers/runtime-spec#1225 and #4013).
A follow-up to #5503.