Skip to content

feat(cgroup2fs): support extended attributes on cgroup directories#13655

Open
a7i wants to merge 1 commit into
google:masterfrom
a7i:feat/cgroup2-xattr
Open

feat(cgroup2fs): support extended attributes on cgroup directories#13655
a7i wants to merge 1 commit into
google:masterfrom
a7i:feat/cgroup2-xattr

Conversation

@a7i

@a7i a7i commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Implement kernfs.InodeWithXattrs on cgroup2 directory inodes using in-memory xattr storage.
  • Allow trusted.*, security.*, and user.* namespaces to match Linux kernfs/cgroup2 behavior.
  • Fixes cgroup2: Support xattrs #13639.

Test plan

  • bazel test //pkg/sentry/fsimpl/cgroup2fs/...
  • Manual: set/get/list/remove xattrs on a cgroup2 directory inside runsc (e.g. trusted.delegate).

Made with Cursor

@google-cla

google-cla Bot commented Jul 8, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@EtiennePerot EtiennePerot requested a review from shailend-g July 8, 2026 23:57
@a7i a7i force-pushed the feat/cgroup2-xattr branch from 38df6e3 to eeae301 Compare July 8, 2026 23:58
Implement kernfs.InodeWithXattrs on cgroup2 directories using in-memory
xattr storage. Allow trusted, security, and user namespaces to match Linux
kernfs/cgroup2 behavior used by systemd.

Fixes google#13639

Signed-off-by: Amir Alavi <amiralavi7@gmail.com>
@a7i a7i force-pushed the feat/cgroup2-xattr branch from eeae301 to 6e0feee Compare July 9, 2026 00:01
@a7i a7i marked this pull request as ready for review July 9, 2026 17:58

@shailend-g shailend-g left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a happy path syscall test to cgroup2.cc for set+get+list+remove.

In addition to the happy path, please consider adding a second test that checks for the fact that without CAP_SYS_ADMIN, the "trusted" xattr cannot be applied and that it cannot be retrieved.

Linux cgroup2 fs allows xattrs on all files, not just dirs. But thats okay: systemd does not apply xattrs on control files, so we can leave that be.

// +checklocks:fs.tasksMu
killSeq uint64

// xattrs stores extended attributes on this cgroup directory. Protected by memxattr.SimpleExtendedAttributes.mu.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop the "Protected by memxattr.SimpleExtendedAttributes.mu." because that is a detail this package doesn't need to know.

"gvisor.dev/gvisor/pkg/sentry/vfs"
"gvisor.dev/gvisor/pkg/sentry/vfs/memxattr"
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider adding a var _ kernfs.InodeWithXattrs = (*cgroup)(nil)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cgroup2: Support xattrs

2 participants