HomeFreeBSD

cxgbe tom: Force unsigned modulus for queue indices.

Description

cxgbe tom: Force unsigned modulus for queue indices.

The final transmit and receive queue indices need to be positive
values. However, since txq_idx and rxq_idx are signed (to permit
using -1 to as a marker for uninitialized values), using %= with
another integer type (vi->nofld[tr]xq) yielded a sign-extended modulus
value. This resulted in negative queue indices and a buffer underrun
when arc4random() returned a value with the sign bit set. Use a
temporary unsigned variable to hold the "raw" queue index to force
unsigned modulus.

This worked previously because the modulus was previously applied
directly to the return value of arc4random() which is unsigned before
the result was assigned to txq_idx and rxq_idx.

Discussed with: np
Fixes: db28d4a0cd1c cxgbe/t4_tom: Support for round-robin selection of offload queues.
Sponsored by: Chelsio Communications

Details

Provenance
jhbAuthored on May 4 2022, 10:59 PM
Parents
rG15881823b9da: rpc.tlsclntd, rpc.tlsservd: Fix getopt_long argument
Branches
Unknown
Tags
Unknown