-
Notifications
You must be signed in to change notification settings - Fork 96
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
bpf: query effective progs without cgroup_mutex #5062
Conversation
Upstream branch: 6e61c5f |
06f28fe
to
33a8512
Compare
Upstream branch: 7b99f75 |
aa9a7de
to
c47a6bc
Compare
33a8512
to
89f2751
Compare
Upstream branch: ee9fd0a |
c47a6bc
to
ddba6a9
Compare
89f2751
to
0b2e9b4
Compare
Upstream branch: bdeeed3 |
ddba6a9
to
6b5eabc
Compare
0b2e9b4
to
330eaf8
Compare
Upstream branch: 79b3604 |
6b5eabc
to
82e986c
Compare
330eaf8
to
cdf37b5
Compare
Upstream branch: 4d585f4 |
1 similar comment
Upstream branch: 4d585f4 |
82e986c
to
53cf208
Compare
cdf37b5
to
5f5d81a
Compare
Upstream branch: d84b1a6 |
53cf208
to
09ed63d
Compare
5f5d81a
to
bc8c7e7
Compare
Upstream branch: 04cb845 |
09ed63d
to
230c022
Compare
bc8c7e7
to
ba80c21
Compare
Upstream branch: 90564f1 |
230c022
to
cec0569
Compare
ba80c21
to
458e551
Compare
Upstream branch: 108598c |
a7303e4
to
3b5fced
Compare
e35e124
to
4d9941c
Compare
Upstream branch: 108598c |
3b5fced
to
6c01c70
Compare
4d9941c
to
73bb5bc
Compare
No functional changes. It will be used later on to copy prog array into a temporary kernel buffer. I'm also changing its return type to errno to be consistent with the rest of the similar helpers. Signed-off-by: Stanislav Fomichev <sdf@google.com>
Same as __hlist_for_each_rcu but uses rcu_dereference_raw to suppress the warning from the update path (which is enforced by extra cond expression). Signed-off-by: Stanislav Fomichev <sdf@google.com>
No functional changes. This patch is here to make it easier to review the next one. We'll be copying buffer to the userspace from the temporary kernel one, so rename prog_ids to user_prog_ids and add new extra variable (p) to traverse it. Also, instead of decrementing total_cnt, introduce new 'remaning' variable to keep track of where we are. We'll need original total_cnt in the next patch to know how many bytes to copy back. Signed-off-by: Stanislav Fomichev <sdf@google.com>
Upstream branch: 108598c |
When querying bpf prog list, we don't really need to hold cgroup_mutex. There is only one caller of cgroup_bpf_query (cgroup_bpf_prog_query) and it does cgroup_get/put, so we're safe WRT cgroup going way. However, we if we stop grabbing cgroup_mutex, we risk racing with the prog attach/detach path to the same cgroup, so here is how to work it around. We have two case: 1. querying effective array 2. querying non-effective list (1) is easy because it's already a RCU-managed array, so all we need is to make a copy of that array (under rcu read lock) into a temporary buffer and copy that temporary buffer back to userspace. (2) is more involved because we keep the list of progs and it's not managed by RCU. However, it seems relatively simple to convert that hlist to the RCU-managed one: convert the readers to use hlist_xxx_rcu and replace kfree with kfree_rcu. One other notable place is cgroup_bpf_release where we replace hlist_for_each_entry_safe with hlist_for_each_entry_rcu. This should be safe because hlist_del_rcu does not remove/poison forward pointer of the list entry, so it's safe to remove the elements while iterating (without specially flavored for_each_safe wrapper). For (2), we also need to take care of flags. I added a bunch of READ_ONCE/WRITE_ONCE to annotate lockless access. And I also moved flag update path to happen before adding prog to the list to make sure readers observe correct flags. Signed-off-by: Stanislav Fomichev <sdf@google.com>
6c01c70
to
7c48551
Compare
73bb5bc
to
5ef086f
Compare
Upstream branch: 3879122 Pull request is NOT updated. Failed to apply https://patchwork.kernel.org/project/netdevbpf/list/?series=746854
conflict:
|
b48ebc5
to
878ccbd
Compare
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=746854 expired. Closing PR. |
Pull request for series with
subject: bpf: query effective progs without cgroup_mutex
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=746854