HomeFreeBSD

iflib: Fix handling of mbuf cluster allocation failures.

Description

iflib: Fix handling of mbuf cluster allocation failures.

When refilling an rx freelist, make sure we only update the hardware
producer index if at least one cluster was allocated. Otherwise the
NIC is programmed to write a previously used cluster, typically
resulting in a use-after-free when packet data is written by the
hardware.

Also make sure that we don't update the fragment index cursor if the
last allocation attempt didn't succeed. For at least Intel drivers,
iflib assumes that the consumer index and fragment index cursor stay in
lockstep, but this assumption was violated in the face of cluster
allocation failures.

Reported and tested by: pho
Reviewed by: gallatin, hselasky
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25489

Details

Provenance
markjAuthored on
Reviewer
gallatin
Differential Revision
D25489: iflib: Fix handling of mbuf cluster allocation failures.
Parents
rS362961: MFC r362338:
Branches
Unknown
Tags
Unknown