Skip to content

Commit 93a4b36

Browse files
Nirbhay Sharmahtejun
authored andcommitted
cgroup: Fix seqcount lockdep assertion in cgroup freezer
The commit afa3701 ("cgroup: cgroup.stat.local time accounting") introduced a seqcount to track freeze timing but initialized it as a plain seqcount_t using seqcount_init(). However, the write-side critical section in cgroup_do_freeze() holds the css_set_lock spinlock while calling write_seqcount_begin(). On PREEMPT_RT kernels, spinlocks do not disable preemption, causing the lockdep assertion for a plain seqcount_t, which checks for preemption being disabled, to fail. This triggers the following warning: WARNING: CPU: 0 PID: 9692 at include/linux/seqlock.h:221 Fix this by changing the type to seqcount_spinlock_t and initializing it with seqcount_spinlock_init() to associate css_set_lock with the seqcount. This allows lockdep to correctly validate that the spinlock is held during write operations, resolving the assertion failure on all kernel configurations. Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=27a2519eb4dad86d0156 Fixes: afa3701 ("cgroup: cgroup.stat.local time accounting") Signed-off-by: Nirbhay Sharma <[email protected]> Link: https://lore.kernel.org/r/[email protected]/ Acked-by: Michal Koutný <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent e406d57 commit 93a4b36

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

include/linux/cgroup-defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ struct cgroup_freezer_state {
452452
int nr_frozen_tasks;
453453

454454
/* Freeze time data consistency protection */
455-
seqcount_t freeze_seq;
455+
seqcount_spinlock_t freeze_seq;
456456

457457
/*
458458
* Most recent time the cgroup was requested to freeze.

kernel/cgroup/cgroup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5892,7 +5892,7 @@ static struct cgroup *cgroup_create(struct cgroup *parent, const char *name,
58925892
* if the parent has to be frozen, the child has too.
58935893
*/
58945894
cgrp->freezer.e_freeze = parent->freezer.e_freeze;
5895-
seqcount_init(&cgrp->freezer.freeze_seq);
5895+
seqcount_spinlock_init(&cgrp->freezer.freeze_seq, &css_set_lock);
58965896
if (cgrp->freezer.e_freeze) {
58975897
/*
58985898
* Set the CGRP_FREEZE flag, so when a process will be

0 commit comments

Comments
 (0)