Skip to content

Commit

Permalink
cgroup: Remove data-race around cgrp_dfl_visible
Browse files Browse the repository at this point in the history
There's a seemingly harmless data-race around cgrp_dfl_visible detected by
kernel concurrency sanitizer. Let's remove it by throwing WRITE/READ_ONCE at
it.

Signed-off-by: Tejun Heo <[email protected]>
Reported-by: Abhishek Shah <[email protected]>
Cc: Gabriel Ryan <[email protected]>
Reviewed-by: Christian Brauner (Microsoft) <[email protected]>
Link: https://lore.kernel.org/netdev/20220819072256.fn7ctciefy4fc4cu@wittgenstein/
  • Loading branch information
htejun committed Sep 4, 2022
1 parent c0f2df4 commit dc79ec1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/cgroup/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -2173,7 +2173,7 @@ static int cgroup_get_tree(struct fs_context *fc)
struct cgroup_fs_context *ctx = cgroup_fc2context(fc);
int ret;

cgrp_dfl_visible = true;
WRITE_ONCE(cgrp_dfl_visible, true);
cgroup_get_live(&cgrp_dfl_root.cgrp);
ctx->root = &cgrp_dfl_root;

Expand Down Expand Up @@ -6098,7 +6098,7 @@ int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns,
struct cgroup *cgrp;
int ssid, count = 0;

if (root == &cgrp_dfl_root && !cgrp_dfl_visible)
if (root == &cgrp_dfl_root && !READ_ONCE(cgrp_dfl_visible))
continue;

seq_printf(m, "%d:", root->hierarchy_id);
Expand Down

0 comments on commit dc79ec1

Please sign in to comment.