From owner-svn-src-all@freebsd.org Sat Jun 20 17:22:47 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4DEA535697D; Sat, 20 Jun 2020 17:22:47 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49q2Yg1RF3z4PCW; Sat, 20 Jun 2020 17:22:47 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2C773FD3A; Sat, 20 Jun 2020 17:22:47 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 05KHMlHu018178; Sat, 20 Jun 2020 17:22:47 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05KHMlGc018177; Sat, 20 Jun 2020 17:22:47 GMT (envelope-from cem@FreeBSD.org) Message-Id: <202006201722.05KHMlGc018177@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Sat, 20 Jun 2020 17:22:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362439 - head/sys/dev/oce X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/sys/dev/oce X-SVN-Commit-Revision: 362439 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Jun 2020 17:22:47 -0000 Author: cem Date: Sat Jun 20 17:22:46 2020 New Revision: 362439 URL: https://svnweb.freebsd.org/changeset/base/362439 Log: 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 Reviewed by: markj, rstone Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D25364 Modified: head/sys/dev/oce/oce_if.c Modified: head/sys/dev/oce/oce_if.c ============================================================================== --- head/sys/dev/oce/oce_if.c Sat Jun 20 15:44:15 2020 (r362438) +++ head/sys/dev/oce/oce_if.c Sat Jun 20 17:22:46 2020 (r362439) @@ -1225,6 +1225,11 @@ retry: */ 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, 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;