aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNavdeep Parhar <np@FreeBSD.org>2020-07-13 19:15:29 +0000
committerNavdeep Parhar <np@FreeBSD.org>2020-07-13 19:15:29 +0000
commit800535c2caf21df3a4b2609c430ed5165ceae2ad (patch)
tree82a680d598324b633491b20250f09cc20afa0a71
parent165236a101f4f89ecb800bf31d148911b37823e7 (diff)
downloadsrc-800535c2caf21df3a4b2609c430ed5165ceae2ad.tar.gz
src-800535c2caf21df3a4b2609c430ed5165ceae2ad.zip
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
Notes
Notes: svn path=/head/; revision=363167
-rw-r--r--sys/dev/cxgbe/t4_sge.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c
index 65f616b1ea45..2cbfc8d5ae52 100644
--- a/sys/dev/cxgbe/t4_sge.c
+++ b/sys/dev/cxgbe/t4_sge.c
@@ -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 *txq, struct mbuf *m0)
* 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