fix symlink resolution for noble#200
Conversation
aramprice
left a comment
There was a problem hiding this comment.
Thank you for the changes, this look good code wise. I would appreciate some other folks looking at it as well, especially to think over any potential security changes from this.
Before this change we allowed an inside-container-mount of an outside-the-container-symlink to resolve at container runtime, from inside the container to the outside-container-symlink-target.
With this change bpm will pre-resolve, not at container runtime, an outside-the-container-symlink to its outside-the-container-symlink-target (not mediated by the container subsystem), and then an inside-the-container-mount will be created which points directly to the outside-the-container-symlink-target
I think this change introduces a difference in the time at which a symlink is resolved (container-creation vs. ad hoc during container runtime)... and I'm curious if this is consequential to the security posture of bpm. I don't think this is the case for the issue mentioned in #199...
I'm wondering if this could have implications in arbitrary cases?
SummaryThis fix resolves symlink handling for bind mounts in BPM containers on Noble (Ubuntu 24.04) stemcells. While initially observed on GCP, this affects all major cloud providers when using instance types without ephemeral storage, which is becoming increasingly common due to cost optimization. The ProblemWhen BOSH builds stemcells for instances without ephemeral disks ( /var/vcap/packages → /var/vcap/data/packages Noble's stricter mount namespace handling causes BPM bind mounts to fail on symlinked paths, resulting in permission denied errors. The FixUse Multi-Cloud EvidenceInstance Types Without Ephemeral Storage
All Stemcell Builders Use This Pattern
Why Merge This
ConclusionThis isn't GCP-specific, it happens across all clouds as they move toward storage-optimized instances. The fix is universal for all cloud providers, safe, and prevents failures as we roll out Noble stemcells. |
|
Possibly look into https://ebpf.io/ changes between Jammy and Noble as a possible root cause for this (new in Noble?) symlink resolution problem. per @rkoster |
|
Thanks @aramprice! I looked into this and it's actually kernel 6.8 mount namespace changes, not eBPF. From the LWN article on mounting images in user namespaces:
This separation of mount vs superblock ownership in kernel 6.8 is probably what's preventing symlink resolution across namespace boundaries. This PR pre-resolves symlinks on the host side. |
| resolvedFrom := from | ||
| if resolved, err := filepath.EvalSymlinks(from); err == nil { | ||
| resolvedFrom = resolved |
There was a problem hiding this comment.
If EvalSymlinks fails (e.g., path doesn't exist yet, permission denied), the error is silently ignored and the original path is used. This works for backward compatibility, but it means symlink resolution failure might make mount issues hard to diagnose.
I'm not sure the tradeoff of adding logging down at this level is the right move though....
|
Perhaps symlinks could be resolved in This would make it possible to log issues with symlink evaluation, and potentially, limit the symlink resolution to a set of white-listed paths (like |
Fixes #199