overlay: use userxattr on tmpfs when it supports user xattrs #14558
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 405 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.359
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #14558"
general
weight: 0.35
AkihiroSuda
Fixes #14557
NeedsUserXAttralways returnsfalsewhen the snapshotter root is on tmpfs. This was added in #7772 (for #7770), because tmpfs used to rejectuser.xattrs, and overlayfs mounted withuserxattrfails on such a backing filesystem.Since Linux 6.6, tmpfs supports
user.xattrs. In a user namespace on these kernels, overlayfs mounted withoutuserxattrstores its metadata intrusted.overlay.xattrs, which cannot be set there. As a result, removing or renaming a directory from a lower layer fails withEIO/EXDEVwhen rootless containerd runs with its root directory on tmpfs.This PR replaces the unconditional
return falsewith a probe: on tmpfs, it tries to set auser.xattr on a temporary file in the snapshotter root, and only skipsuserxattrif the filesystem rejects it (ENOTSUP/EPERM). On other errors it returns the error, and the caller falls back to not usinguserxattr, as before.CONFIG_TMPFS_XATTR).Testing
I ran the existing overlay snapshotter tests in a user namespace with
TMPDIRon a tmpfs (Linux 6.19):Without this change, the following tests fail (for each of
no_opt,AsynchronousRemoveandWithRemapIDs), and with this change they pass:TestOverlay//RemoveDirectoryInLowerLayerTestOverlay//MoveFileFromLowerLayerTestOverlay//BasicTestOverlay//128LayersMountOther failures in this setup are unrelated to this change and also happen without it:
Chown,DirectoryPermissionOnCommit,TestOverlayRemapped:unshare -Urmaps only a single UID/GID.TestOverlayOverlayMount: the test expectsindex=offbeforeuserxattr, but the snapshotter appendsuserxattrfirst. This fails wheneveruserxattris used, e.g. also without this change when run in a user namespace on ext4.I also tested the fix in our setup, where the overlay snapshotter runs in a user namespace with its root on a tmpfs: with
userxattr, directories from lower layers can be removed and renamed again.About unit tests
I considered adding a unit test, but I could not find a meaningful way to test this:
userns.RunningInUserNS()), which cannot be faked within a test.make root-testruns as real root, whereNeedsUserXAttrreturns early, and the CRI-in-UserNS job does not use tmpfs.If someone has an idea how to test this properly, I'm happy to add a test.