Repository navigation
[cgroup] fix uint32 overflow in CPU quota computation - #348
Open
ManoharPaturi wants to merge 1 commit into
Open
ManoharPaturi wants to merge 1 commit into
ManoharPaturi wants to merge 1 commit into
Conversation
cgroup_cpu_ms_per_sec is a uint32 config field. Computing the microsecond quota with '* 1000U' evaluates in 32 bits, so any value >= 4294968 wraps around: e.g. 4294968 becomes a 704us quota and 5000000 becomes 705032704us, silently writing a limit that has nothing to do with the configured one. Compute in uint64_t in both the v1 (cgroup.cc) and v2 (cgroup2.cc) writers.
ManoharPaturi
force-pushed
the
pr-cgroup-quota
branch
from
September 27, 2026 08:58
42b8483 to
653187d
Compare
Author
|
Small branch hygiene fix: my local CI workflow file accidentally ended up in this branch — force-pushed the branch rebuilt from current master with only the intended change. The diff is now just the patch itself; the actions scan failure from earlier is gone. |
Author
|
@robertswiecki Could you take a look when you have a moment? This fixes a uint32 overflow in the CPU quota computation: |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
cgroup_cpu_ms_per_secis auint32config field, and both quota writers compute the microsecond value with* 1000U, which evaluates in 32 bits. Any configured value ≥ 4294968 wraps around and writes a completely unrelated limit to the kernel:So an operator requesting ~4300 CPU-seconds per second silently gets a 704 µs quota in cgroup v1, and cgroup v2 gets an arbitrary wrapped
cpu.maxvalue — the enforced limit has no relation to the configuration.Change
Compute the quota in
uint64_tin both writers (cgroup.ccfor v1,cgroup2.ccfor v2). No behavior change for values that don't overflow.Testing
Built and ran the full test suite (unit + cmdline) plus an ASan/UBSan build on Ubuntu 24.04 — all green, no new findings. The overflow itself is demonstrated by the table above (plain uint32 arithmetic).