fix(runtime): ignore child mounts during container detection - #65494
fix(runtime): ignore child mounts during container detection#65494the3asic wants to merge 2 commits into
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for targeting the verified cgroup-v2 false positive: current main still scans the whole mountinfo payload at hermes_constants.py:1131-1135.
Problems
- In the added helper,
hermes_constants.py:1118searches the entire raw root-mount line after filtering on field 5. That also searches the mount source. A host root source such as/dev/mapper/docker--vg-rootwould matchdockerdespite being device provenance, not containment. The proposed tests cover marker-bearing root overlays but not this false-positive shape.
Suggested changes
- Parse the separator and probe only mountinfo field 3 plus super options after
-; exclude filesystem type and source. - Add an
is_container()regression test for a markerless cgroup plus/dev/mapper/docker--vg-rootroot source. - Please consolidate the preferred scope with the linked #58141 / #65060 variants, as noted in the existing member comment.
Automated hermes-sweeper review.
| if mount_point == "/" and any( | ||
| marker in line.lower() for marker in runtime_markers | ||
| ): | ||
| return True |
There was a problem hiding this comment.
This scans the complete root-mount row, including the mount source. A host root such as /dev/mapper/docker--vg-root would match docker even though that names the backing device rather than a container runtime. Parse mountinfo and restrict the probe to the filesystem-root field and super options after -.
|
Scope note from the triage pointer to #58141 / #65060: both of those change |
The root-mount scan still matched runtime markers against the whole mountinfo line, so a host root on a backing device such as /dev/mapper/docker--vg-root was reported as a container. Match only the mount point, the root path, the fstype, and the super options; keep the mount source and pre-separator device fields out of the scan. Adds the device-name false-positive cases and a super-options true positive to the mountinfo tests.
|
Addressed in 5626de2. Runtime-marker matching now excludes the mount-source field after the mountinfo separator, so a host root backed by a device such as |
What does this PR do?
The Linux container fallback currently scans all of
/proc/self/mountinfofor runtime markers. A normal host that runs Docker or containerd can therefore be misclassified as a container because one of its child mounts contains a runtime path.This change:
/;Verification
pytest tests/test_hermes_constants.py -q— 132 passedruff check hermes_constants.py tests/test_hermes_constants.pypython -m py_compile hermes_constants.py tests/test_hermes_constants.pygit diff --checkThe tests use synthetic mountinfo rows and do not read live
/proc, credentials, or environment-specific paths.