Skip to content

Fix: Replace libc rand() with DPDK PRNG in RX loss simulators - #1694

Open
awilczyns wants to merge 1 commit into
mainfrom
fix/cid-561265-rx-loss-sim-prng
Open

Fix: Replace libc rand() with DPDK PRNG in RX loss simulators#1694
awilczyns wants to merge 1 commit into
mainfrom
fix/cid-561265-rx-loss-sim-prng

Conversation

@awilczyns

Copy link
Copy Markdown
Collaborator

Coverity CID 561265 (DC.WEAK_CRYPTO / CWE-676) flags rand() in ra_simulate_pkt_loss(). The security premise does not apply: the value only decides whether to drop a packet in a fault injector armed by ST30_RX_FLAG_SIMULATE_PKT_LOSS, and feeds no key, nonce, token or authorization decision. rte_drand() is likewise not cryptographically secure, so this is not a security improvement.

The real defect at those lines is a two-world-rule violation: glibc rand() takes a process-global lock on every call, so with the flag armed each received packet serializes the RX polling tasklet against every other rand() caller in the process, including RX tasklets of other sessions on other lcores. rte_drand()/rte_rand_max() use per-lcore LFSR258 state with no lock, and rte_rand_max() is unbiased unlike % max.

Value range is unchanged: burst_loss_max is always >= 1 (attach defaults 0 to 1), so both forms yield [1, burst_loss_max]. No new test accompanies this change because it has no observable behavioral delta; the existing St30p.rx_simulate_pkt_loss integration case covers the path.

Applied to the identical video sibling rv_simulate_pkt_loss() so the same CID cannot reappear there.

Coverity CID 561265 (DC.WEAK_CRYPTO / CWE-676) flags rand() in
ra_simulate_pkt_loss(). The security premise does not apply: the value only
decides whether to drop a packet in a fault injector armed by
ST30_RX_FLAG_SIMULATE_PKT_LOSS, and feeds no key, nonce, token or
authorization decision. rte_drand() is likewise not cryptographically
secure, so this is not a security improvement.

The real defect at those lines is a two-world-rule violation: glibc rand()
takes a process-global lock on every call, so with the flag armed each
received packet serializes the RX polling tasklet against every other
rand() caller in the process, including RX tasklets of other sessions on
other lcores. rte_drand()/rte_rand_max() use per-lcore LFSR258 state with
no lock, and rte_rand_max() is unbiased unlike `% max`.

Value range is unchanged: burst_loss_max is always >= 1 (attach defaults 0
to 1), so both forms yield [1, burst_loss_max]. No new test accompanies
this change because it has no observable behavioral delta; the existing
St30p.rx_simulate_pkt_loss integration case covers the path.

Applied to the identical video sibling rv_simulate_pkt_loss() so the same
CID cannot reappear there.

Signed-off-by: Wilczynski, Andrzej <andrzej.wilczynski@intel.com>
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