alc_rxeof() trusted the Rx return descriptor: the 12-bit RD_IDX field
indexed the 256-entry Rx descriptor ring, and the frame length sized the
mbuf chain, both without validation. A bad index reads outside the
ring, and a length that doesn't match the segment count gives mbufs with
a negative length or one past the end of the cluster. Drop such frames
and count them as input errors.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
| sys/dev/alc/if_alc.c | ||
|---|---|---|
| 3640 | We should also increment IFCOUNTER_IERRORS here. | |
Comment Actions
Good catch. Added if_inc_counter(ifp, IFCOUNTER_IERRORS, 1) in the reject branch, matching the idiom used for malformed Rx descriptors in sge_rxeof() (sys/dev/sge/if_sge.c). ifp was already in scope there.
| sys/dev/alc/if_alc.c | ||
|---|---|---|
| 3644 | What about this value? We're trusting it to be valid as well. What if it's smaller than ETHER_CRC_LEN? | |
Comment Actions
Right, it's trusted as well. A length that doesn't match the segment
count gives a negative m_len, or one past the end of the cluster. The
frame is now dropped unless the length is larger than ETHER_CRC_LEN and
fits the segment count, i.e. (nsegs - 1) * alc_buf_size < len <=
nsegs * alc_buf_size.
age(4) and jme(4) have the same problem, I'll look at those separately.