fix(pawnio): cap broker SMBus batch delay#74
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR adds input validation to SMBus batch delay operations by introducing a maximum delay duration constant and validation function. The validation is integrated into batch execution to reject oversized delays, and unit tests verify the rejection behavior. ChangesBatch Delay Validation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The Delay batch op already carries a u64 duration, so u64::from on it is a useless conversion that trips clippy on Windows targets. Format the batch-delay validation to satisfy cargo fmt as well.
b1be1dd to
c55bcb0
Compare
Motivation
Delay { duration_ms }operations inSmBusXferBatchand executedthread::sleepwhile holding the globalbusesmutex, allowing a local interactive process to block broker worker threads and cause an availability DoS.Description
MAX_BATCH_DELAY_MS = 1_000and validate incoming batch delays with a newvalidate_batch_delay_mshelper.PawnIoError::InvalidInputinstead of sleeping for the supplied duration insideBrokerState::smbus_xfer_batch.thread::sleepfor values at-or-below the cap.batch_delay_rejects_values_above_maximumto assert that values above the cap are rejected.Testing
cargo test -p hypercolor-windows-pawnio --liband the crate built and tested successfully in this environment (test runner completed with no failing tests).Codex Task
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests