From owner-svn-src-head@freebsd.org Mon Jul 13 19:15:30 2020 Return-Path: Delivered-To: svn-src-head@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 A43BE36DF58; Mon, 13 Jul 2020 19:15:30 +0000 (UTC) (envelope-from np@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 4B5Cz63ZzZz4P4S; Mon, 13 Jul 2020 19:15:30 +0000 (UTC) (envelope-from np@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 5A2F919FD8; Mon, 13 Jul 2020 19:15:30 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 06DJFUFR057737; Mon, 13 Jul 2020 19:15:30 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 06DJFUCZ057736; Mon, 13 Jul 2020 19:15:30 GMT (envelope-from np@FreeBSD.org) Message-Id: <202007131915.06DJFUCZ057736@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Mon, 13 Jul 2020 19:15:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363167 - head/sys/dev/cxgbe X-SVN-Group: head X-SVN-Commit-Author: np X-SVN-Commit-Paths: head/sys/dev/cxgbe X-SVN-Commit-Revision: 363167 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jul 2020 19:15:30 -0000 Author: np Date: Mon Jul 13 19:15:29 2020 New Revision: 363167 URL: https://svnweb.freebsd.org/changeset/base/363167 Log: cxgbev(4): Compare at most 16 bytes of the Ethernet header when trying to coalesce tx work requests. Note that Coverity will still treat this as an out-of-bounds access. We do want to compare 16B starting from ethmacdst but cmp_l2hdr was was going beyond that by 2B. cmp_l2hdr was introduced in r362905. Reported by: Coverity (CID 1430284) Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/t4_sge.c Modified: head/sys/dev/cxgbe/t4_sge.c ============================================================================== --- head/sys/dev/cxgbe/t4_sge.c Mon Jul 13 19:10:16 2020 (r363166) +++ head/sys/dev/cxgbe/t4_sge.c Mon Jul 13 19:15:29 2020 (r363167) @@ -4700,6 +4700,8 @@ csum_to_ctrl(struct adapter *sc, struct mbuf *m) return (ctrl); } +#define VM_TX_L2HDR_LEN 16 /* ethmacdst to vlantci */ + /* * Write a VM txpkt WR for this packet to the hardware descriptors, update the * software descriptor, and advance the pidx. It is guaranteed that enough @@ -4748,7 +4750,7 @@ write_txpkt_vm_wr(struct adapter *sc, struct sge_txq * * conditional. Also, it seems that we do not have to set * vlantci or fake the ethtype when doing VLAN tag insertion. */ - m_copydata(m0, 0, sizeof(struct ether_header) + 2, wr->ethmacdst); + m_copydata(m0, 0, VM_TX_L2HDR_LEN, wr->ethmacdst); if (needs_tso(m0)) { struct cpl_tx_pkt_lso_core *lso = (void *)(wr + 1); @@ -4985,10 +4987,10 @@ cmp_l2hdr(struct txpkts *txp, struct mbuf *m) int len; MPASS(txp->npkt > 0); - MPASS(m->m_len >= 16); /* type1 implies 1 GL with all of the frame. */ + MPASS(m->m_len >= VM_TX_L2HDR_LEN); if (txp->ethtype == be16toh(ETHERTYPE_VLAN)) - len = sizeof(struct ether_vlan_header); + len = VM_TX_L2HDR_LEN; else len = sizeof(struct ether_header); @@ -4998,9 +5000,9 @@ cmp_l2hdr(struct txpkts *txp, struct mbuf *m) static inline void save_l2hdr(struct txpkts *txp, struct mbuf *m) { - MPASS(m->m_len >= 16); /* type1 implies 1 GL with all of the frame. */ + MPASS(m->m_len >= VM_TX_L2HDR_LEN); - memcpy(&txp->ethmacdst[0], mtod(m, const void *), 16); + memcpy(&txp->ethmacdst[0], mtod(m, const void *), VM_TX_L2HDR_LEN); } static int