oce(4): Account and trace mbufs before handing to hw

Once tx mbufs have been handed to hardware, nothing serializes the tx
path against completion and potential use-after-free of the outbound
mbuf.  Perform accounting and BPF tap before queueing to hardware to
avoid this race.

Submitted by:	Steve Wirtz <steve_wirtz AT dell.com>
Reviewed by:	markj, rstone
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D25364
This commit is contained in:
Conrad Meyer 2020-06-20 17:22:46 +00:00
parent 75dc9c41ab
commit b75a772875
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=362439

View File

@ -1225,6 +1225,11 @@ oce_tx(POCE_SOFTC sc, struct mbuf **mpp, int wq_index)
*/
oce_is_pkt_dest_bmc(sc, m, &os2bmc, &m_new);
if_inc_counter(sc->ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len);
if (m->m_flags & M_MCAST)
if_inc_counter(sc->ifp, IFCOUNTER_OMCASTS, 1);
ETHER_BPF_MTAP(sc->ifp, m);
OCE_WRITE_REG32(sc, db, wq->db_offset, reg_value);
} else if (rc == EFBIG) {
@ -1400,7 +1405,7 @@ oce_start(struct ifnet *ifp)
if (!sc->link_status)
return;
do {
while (true) {
IF_DEQUEUE(&sc->ifp->if_snd, m);
if (m == NULL)
break;
@ -1417,12 +1422,7 @@ oce_start(struct ifnet *ifp)
}
break;
}
if (m != NULL)
ETHER_BPF_MTAP(ifp, m);
} while (TRUE);
return;
}
}
@ -1500,10 +1500,6 @@ oce_multiq_transmit(struct ifnet *ifp, struct mbuf *m, struct oce_wq *wq)
break;
}
drbr_advance(ifp, br);
if_inc_counter(ifp, IFCOUNTER_OBYTES, next->m_pkthdr.len);
if (next->m_flags & M_MCAST)
if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1);
ETHER_BPF_MTAP(ifp, next);
}
return 0;