]> git.ipfire.org Git - thirdparty/util-linux.git/commit
uclampset: fix lost-update race in set_uclamp_one()
authorFurkan Caliskan <frn1furkan10@gmail.com>
Sun, 31 May 2026 08:36:58 +0000 (11:36 +0300)
committerFurkan Caliskan <frn1furkan10@gmail.com>
Sun, 31 May 2026 08:42:30 +0000 (11:42 +0300)
commit9da4183594dfd9e816e8db00f0c9c9fef239a175
tree8ebd6ed77718a6a7ef60d302a191b8ffed0d8610
parentd968218c72c6a66d792610cf47a52b79f9bc8363
uclampset: fix lost-update race in set_uclamp_one()

The function unconditionally sets both SCHED_FLAG_UTIL_CLAMP_MIN and
SCHED_FLAG_UTIL_CLAMP_MAX in sa.sched_flags regardless of which values
the user actually requested to change.

This creates a lost-update race: sched_getattr() fetches the current
clamp values, but between that call and sched_setattr(), another thread
may legitimately update the value we did not intend to touch. Because
both flags are always set, sched_setattr() forces the kernel to apply
the stale cached value, silently overwriting the concurrent update.

Fix by setting the flags conditionally.

Signed-off-by: Furkan Caliskan <frn1furkan10@gmail.com>
schedutils/uclampset.c