Skip to content

Commit f0cc749

Browse files
Tetsuo Handahtejun
authored andcommitted
cgroup,freezer: hold cpu_hotplug_lock before freezer_mutex in freezer_css_{online,offline}()
syzbot is again reporting circular locking dependency between cpu_hotplug_lock and freezer_mutex. Do like what we did with commit 57dcd64 ("cgroup,freezer: hold cpu_hotplug_lock before freezer_mutex"). Reported-by: syzbot <[email protected]> Closes: https://syzkaller.appspot.com/bug?extid=2ab700fe1829880a2ec6 Signed-off-by: Tetsuo Handa <[email protected]> Tested-by: syzbot <[email protected]> Fixes: f5d39b0 ("freezer,sched: Rewrite core freezer logic") Cc: [email protected] # v6.1+ Signed-off-by: Tejun Heo <[email protected]>
1 parent 5647e53 commit f0cc749

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

kernel/cgroup/legacy_freezer.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,18 @@ static int freezer_css_online(struct cgroup_subsys_state *css)
108108
struct freezer *freezer = css_freezer(css);
109109
struct freezer *parent = parent_freezer(freezer);
110110

111+
cpus_read_lock();
111112
mutex_lock(&freezer_mutex);
112113

113114
freezer->state |= CGROUP_FREEZER_ONLINE;
114115

115116
if (parent && (parent->state & CGROUP_FREEZING)) {
116117
freezer->state |= CGROUP_FREEZING_PARENT | CGROUP_FROZEN;
117-
static_branch_inc(&freezer_active);
118+
static_branch_inc_cpuslocked(&freezer_active);
118119
}
119120

120121
mutex_unlock(&freezer_mutex);
122+
cpus_read_unlock();
121123
return 0;
122124
}
123125

@@ -132,14 +134,16 @@ static void freezer_css_offline(struct cgroup_subsys_state *css)
132134
{
133135
struct freezer *freezer = css_freezer(css);
134136

137+
cpus_read_lock();
135138
mutex_lock(&freezer_mutex);
136139

137140
if (freezer->state & CGROUP_FREEZING)
138-
static_branch_dec(&freezer_active);
141+
static_branch_dec_cpuslocked(&freezer_active);
139142

140143
freezer->state = 0;
141144

142145
mutex_unlock(&freezer_mutex);
146+
cpus_read_unlock();
143147
}
144148

145149
static void freezer_css_free(struct cgroup_subsys_state *css)

0 commit comments

Comments
 (0)