← Back to Pull requests

overlay: use userxattr on tmpfs when it supports user xattrs #14558

Open
unknown opened this pull request with 405 lines diff across 5 files
View on GitHub
unknown unknown commented on Nov 11, 2026 22:15 UTC
Author

Fixes #14557

NeedsUserXAttr always returns false when the snapshotter root is on tmpfs. This was added in #7772 (for #7770), because tmpfs used to reject user. xattrs, and overlayfs mounted with userxattr fails on such a backing filesystem.

Since Linux 6.6, tmpfs supports user. xattrs. In a user namespace on these kernels, overlayfs mounted without userxattr stores its metadata in trusted.overlay. xattrs, which cannot be set there. As a result, removing or renaming a directory from a lower layer fails with EIO/EXDEV when rootless containerd runs with its root directory on tmpfs.

This PR replaces the unconditional return false with a probe: on tmpfs, it tries to set a user. xattr on a temporary file in the snapshotter root, and only skips userxattr if the filesystem rejects it (ENOTSUP/EPERM). On other errors it returns the error, and the caller falls back to not using userxattr, as before.

  • A probe is used instead of a kernel version check, as the support may be backported or disabled (CONFIG_TMPFS_XATTR).

  • On kernels before 6.6, the probe fails and the behavior from #7770 is kept.

  • The behavior on filesystems other than tmpfs is unchanged.
  • Testing

    I ran the existing overlay snapshotter tests in a user namespace with TMPDIR on a tmpfs (Linux 6.19):

    go test -c -o /tmp/ovl.test ./plugins/snapshots/overlay/
    cd plugins/snapshots/overlay
    unshare -Urm sh -c 'mkdir -p /tmp/ovl && mount -t tmpfs tmpfs /tmp/ovl && TMPDIR=/tmp/ovl /tmp/ovl.test -test.root -test.v -test.run TestOverlay'
    

    Without this change, the following tests fail (for each of no_opt, AsynchronousRemove and WithRemapIDs), and with this change they pass:

  • TestOverlay//RemoveDirectoryInLowerLayer

  • TestOverlay//MoveFileFromLowerLayer

  • TestOverlay//Basic

  • TestOverlay//128LayersMount
  • Other failures in this setup are unrelated to this change and also happen without it:

  • Chown, DirectoryPermissionOnCommit, TestOverlayRemapped: unshare -Ur maps only a single UID/GID.

  • TestOverlayOverlayMount: the test expects index=off before userxattr, but the snapshotter appends userxattr first. This fails whenever userxattr is 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:

  • The changed code is only reached when the process runs in a user namespace (userns.RunningInUserNS()), which cannot be faked within a test.

  • Whether the probe succeeds depends on the kernel the test runs on, so a test that mounts a tmpfs and runs the probe would mostly test the kernel, not this code.

  • The existing kernel version fast path (>= 5.11) and the previous tmpfs check (#7772) have the same problem, and have no unit tests either.

  • In CI, make root-test runs as real root, where NeedsUserXAttr returns 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.

    Diff: 405 lines (+303 / -102) across 5 files Reviewer: AkihiroSuda Review duration: 3349m
    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
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.8% (MEDIUM) · Higher = larger blast radius
    44.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23.9% · Safe to merge
    23.9%