Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cgroup: Fix seqcount lockdep assertion in cgroup freezer

The commit afa3701c0e45 ("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: syzbot+27a2519eb4dad86d0156@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=27a2519eb4dad86d0156
Fixes: afa3701c0e45 ("cgroup: cgroup.stat.local time accounting")
Signed-off-by: Nirbhay Sharma <nirbhay.lkd@gmail.com>
Link: https://lore.kernel.org/r/20251002165510.KtY3IT--@linutronix.de/
Acked-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Nirbhay Sharma and committed by
Tejun Heo
93a4b36e e406d57b

+2 -2
+1 -1
include/linux/cgroup-defs.h
··· 452 452 int nr_frozen_tasks; 453 453 454 454 /* Freeze time data consistency protection */ 455 - seqcount_t freeze_seq; 455 + seqcount_spinlock_t freeze_seq; 456 456 457 457 /* 458 458 * Most recent time the cgroup was requested to freeze.
+1 -1
kernel/cgroup/cgroup.c
··· 5892 5892 * if the parent has to be frozen, the child has too. 5893 5893 */ 5894 5894 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); 5896 5896 if (cgrp->freezer.e_freeze) { 5897 5897 /* 5898 5898 * Set the CGRP_FREEZE flag, so when a process will be