-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lints: add check for non-utf-8 filesystem content #983
Conversation
e627b9e
to
0d0acdf
Compare
From what I can see of how we get our root On the other hand, any bind mounts that are present might prevent us from scanning the underlying content. Imagine some scenario where Maybe we should do a temporary bind mount of (only) the rootfs for purposes of linting? Thoughts? |
Yeah we should avoid that for sure. There's relevant similar code in e.g. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM apart from the mount traversal you noted, thanks!
I don't really trust checking dev vs. rootdev anymore: we've had some reports of that that show that overlayfs with composefs can produce strange effects in this case... like in containers/composefs-rs#41 (comment) The overlayfs docs themselves warn about this:
https://docs.kernel.org/filesystems/overlayfs.html The openat2 I think the best thing we could do here is some trickery with cloning the root mount to an fd using the new mount API and then iterating through that fd... |
Okay, "some trickery" isn't very tricky at all. It mostly looks like just using https://github.com/brauner/man-pages-md/blob/main/open_tree.md |
Yeah, fair. OK so another approach which is also used in the referenced code is this: #984
Not directly but we can also just use rustix for stuff like this too. |
This came up in containers/bootc#983 and it's actually *really* cool honestly that one can do a non-cloning (detached) `open_tree` without privileges. Let's note that implicitly by documenting that this can return `EPERM`.
0d0acdf
to
5cceec7
Compare
That is awesome! I didn't know that was usable unprivileged. Indeed it's by far the best approach. I noticed this wasn't doc'd so ➡️ brauner/man-pages-md#15 |
5cceec7
to
16d95b7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice thanks!
Ah CI needs some |
As mentioned in containers#975, we should add a lint to ensure that all filenames are UTF-8, giving nice errors (with full pathnames) in the event that we encounter invalid filenames. We also check symlink targets. Add a unit test that tries various valid and invalid scenarios. Signed-off-by: Allison Karlitskaya <[email protected]> Signed-off-by: Colin Walters <[email protected]>
After a live chat we decided to just rely on |
Also noting here just so it doesn't get lost: We also discussed having
An advantage of this approach is that we'd be able to scan the filesystem tree without having container runtime state ( But...the ergonomics would be obviously less good. And ultimately the most powerful way to do this is to have a container scanner that runs outside of the running image, which would allow us to lint the actual image structure itself (e.g. tiny layers that should be coalesced). Or of course, a container -> container optimizer. |
As mentioned in #975, we should add a lint to ensure that all filenames are UTF-8, giving nice errors (with full pathnames) in the event that we encounter invalid filenames.
We also check symlink targets.
Add a unit test that tries various valid and invalid scenarios.