Skip to content

fix(kernel): wrap watch_queue monotonic id counters to avoid overflow#126

Merged
kernalix7 merged 1 commit into
mainfrom
fix/watch-queue-counter-overflow
Jun 11, 2026
Merged

fix(kernel): wrap watch_queue monotonic id counters to avoid overflow#126
kernalix7 merged 1 commit into
mainfrom
fix/watch-queue-counter-overflow

Conversation

@kernalix7

Copy link
Copy Markdown
Owner

Summary

create_queue/create_queue_with_capacity/create_group incremented next_queue_id/next_group_id with a plain += 1. The occupancy guards bound only the concurrently-live count (MAX_QUEUES=256/MAX_GROUPS=64), not the monotonic counter, so over a long-running create/destroy cycle the u32 id reaches u32::MAX and the next increment panics under overflow-checks.

Use wrapping_add, matching the next_*_id idiom already in sysfs_attr.rs/perf_events.rs — the bounded live count makes id reuse after a 2^32 wrap a non-issue.

Latent: WatchQueueSubsystem is an exported pub module with no instance/syscall/dispatch path today. Found by a kernel security-parser fan-out (ptrace/landlock/perf/BTF/io_uring/seccomp/keyring all came back clean).

Verification

  • cargo clippy -p oncrix-kernel -- -D warnings ✓ (0) + cargo build -p oncrix-kernel --target x86_64-unknown-none ✓ (bare-metal) + cargo fmt --all -- --check

create_queue/create_queue_with_capacity/create_group incremented
next_queue_id/next_group_id with a plain '+= 1'. The occupancy guards cap
only the concurrently-live count (MAX_QUEUES=256 / MAX_GROUPS=64), not the
monotonic counter, so over a long-running create/destroy cycle the u32 id
reaches u32::MAX and the next increment panics under overflow-checks.

Use wrapping_add, matching the next_*_id idiom already used in
sysfs_attr.rs and perf_events.rs: the bounded live count makes id reuse
after a 2^32 wrap a non-issue in practice.

Latent: WatchQueueSubsystem is an exported pub module with no instance,
syscall, or dispatch path today.
@kernalix7 kernalix7 merged commit aa2204e into main Jun 11, 2026
2 checks passed
@kernalix7 kernalix7 deleted the fix/watch-queue-counter-overflow branch June 11, 2026 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant