-
Notifications
You must be signed in to change notification settings - Fork 145
Introduce bpf_cgroup_read_xattr #9172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Upstream branch: 99fe8af |
e7d5deb
to
1c12ad1
Compare
Upstream branch: c11f34e |
277c9e4
to
f89554c
Compare
1c12ad1
to
4b5a6fc
Compare
Upstream branch: 3ce7cdd |
f89554c
to
e652224
Compare
4b5a6fc
to
a2a54b8
Compare
Upstream branch: 3ce7cdd |
e652224
to
b0a227d
Compare
a2a54b8
to
2e3dd89
Compare
Upstream branch: 3713b58 |
b0a227d
to
0a903b7
Compare
2e3dd89
to
2881f4b
Compare
Upstream branch: 3713b58 |
0a903b7
to
aea4047
Compare
2881f4b
to
a974116
Compare
Upstream branch: d69bafe |
aea4047
to
07c62e7
Compare
a974116
to
eaa5230
Compare
All allocations of struct kernfs_iattrs are serialized through a global mutex. Simply do a racy allocation and let the first one win. I bet most callers are under inode->i_rwsem anyway and it wouldn't be needed but let's not require that. Signed-off-by: Christian Brauner <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Acked-by: Tejun Heo <[email protected]> Signed-off-by: Song Liu <[email protected]>
BPF programs, such as LSM and sched_ext, would benefit from tags on cgroups. One common practice to apply such tags is to set xattrs on cgroupfs folders. Introduce kfunc bpf_cgroup_read_xattr, which allows reading cgroup's xattr. Note that, we already have bpf_get_[file|dentry]_xattr. However, these two APIs are not ideal for reading cgroupfs xattrs, because: 1) These two APIs only works in sleepable contexts; 2) There is no kfunc that matches current cgroup to cgroupfs dentry. bpf_cgroup_read_xattr is generic and can be useful for many program types. It is also safe, because it requires trusted or rcu protected argument (KF_RCU). Therefore, we make it available to all program types. Signed-off-by: Song Liu <[email protected]> Acked-by: Tejun Heo <[email protected]>
Upstream branch: d83caf7 |
Mark struct cgroup_subsys_state->cgroup as safe under RCU read lock. This will enable accessing css->cgroup from a bpf css iterator. Signed-off-by: Song Liu <[email protected]>
Add tests for different scenarios with bpf_cgroup_read_xattr: 1. Read cgroup xattr from bpf_cgroup_from_id; 2. Read cgroup xattr from bpf_cgroup_ancestor; 3. Read cgroup xattr from css_iter; 4. Use bpf_cgroup_read_xattr in LSM hook security_socket_connect. 5. Use bpf_cgroup_read_xattr in cgroup program. Signed-off-by: Song Liu <[email protected]>
07c62e7
to
8268090
Compare
eaa5230
to
cae7a60
Compare
Pull request for series with
subject: Introduce bpf_cgroup_read_xattr
version: 3
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=974689