Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Fix M_PKTHDR use in if_alc, if_age and if_ena.
details: https://anonhg.NetBSD.org/src/rev/cc8189f13745
branches: trunk
changeset: 319504:cc8189f13745
user: maxv <maxv%NetBSD.org@localhost>
date: Fri Jun 01 09:34:39 2018 +0000
description:
Fix M_PKTHDR use in if_alc, if_age and if_ena.
if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.
Same in if_ena, but this one does not compile so we don't really care.
Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).
diffstat:
sys/dev/pci/if_age.c | 8 ++++----
sys/dev/pci/if_alc.c | 6 +++---
sys/dev/pci/if_ena.c | 4 ++--
3 files changed, 9 insertions(+), 9 deletions(-)
diffs (84 lines):
diff -r 2052d12369ea -r cc8189f13745 sys/dev/pci/if_age.c
--- a/sys/dev/pci/if_age.c Fri Jun 01 09:10:52 2018 +0000
+++ b/sys/dev/pci/if_age.c Fri Jun 01 09:34:39 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_age.c,v 1.51 2017/09/26 07:42:06 knakahara Exp $ */
+/* $NetBSD: if_age.c,v 1.52 2018/06/01 09:34:39 maxv Exp $ */
/* $OpenBSD: if_age.c,v 1.1 2009/01/16 05:00:34 kevlo Exp $ */
/*-
@@ -31,7 +31,7 @@
/* Driver for Attansic Technology Corp. L1 Gigabit Ethernet. */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.51 2017/09/26 07:42:06 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.52 2018/06/01 09:34:39 maxv Exp $");
#include "vlan.h"
@@ -1430,7 +1430,7 @@
sc->age_cdata.age_rxhead = mp;
sc->age_cdata.age_rxtail = mp;
} else {
- mp->m_flags &= ~M_PKTHDR;
+ m_remove_pkthdr(mp);
sc->age_cdata.age_rxprev_tail =
sc->age_cdata.age_rxtail;
sc->age_cdata.age_rxtail->m_next = mp;
@@ -1459,7 +1459,7 @@
}
m = sc->age_cdata.age_rxhead;
- m->m_flags |= M_PKTHDR;
+ KASSERT(m->m_flags & M_PKTHDR);
m_set_rcvif(m, ifp);
m->m_pkthdr.len = sc->age_cdata.age_rxlen;
/* Set the first mbuf length. */
diff -r 2052d12369ea -r cc8189f13745 sys/dev/pci/if_alc.c
--- a/sys/dev/pci/if_alc.c Fri Jun 01 09:10:52 2018 +0000
+++ b/sys/dev/pci/if_alc.c Fri Jun 01 09:34:39 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_alc.c,v 1.25 2017/09/26 07:42:06 knakahara Exp $ */
+/* $NetBSD: if_alc.c,v 1.26 2018/06/01 09:34:39 maxv Exp $ */
/* $OpenBSD: if_alc.c,v 1.1 2009/08/08 09:31:13 kevlo Exp $ */
/*-
* Copyright (c) 2009, Pyun YongHyeon <yongari%FreeBSD.org@localhost>
@@ -2537,7 +2537,7 @@
sc->alc_cdata.alc_rxhead = mp;
sc->alc_cdata.alc_rxtail = mp;
} else {
- mp->m_flags &= ~M_PKTHDR;
+ m_remove_pkthdr(mp);
sc->alc_cdata.alc_rxprev_tail =
sc->alc_cdata.alc_rxtail;
sc->alc_cdata.alc_rxtail->m_next = mp;
@@ -2547,7 +2547,7 @@
if (count == nsegs - 1) {
/* Last desc. for this frame. */
m = sc->alc_cdata.alc_rxhead;
- m->m_flags |= M_PKTHDR;
+ KASSERT(m->m_flags & M_PKTHDR);
/*
* It seems that L1C/L2C controller has no way
* to tell hardware to strip CRC bytes.
diff -r 2052d12369ea -r cc8189f13745 sys/dev/pci/if_ena.c
--- a/sys/dev/pci/if_ena.c Fri Jun 01 09:10:52 2018 +0000
+++ b/sys/dev/pci/if_ena.c Fri Jun 01 09:34:39 2018 +0000
@@ -31,7 +31,7 @@
#if 0
__FBSDID("$FreeBSD: head/sys/dev/ena/ena.c 333456 2018-05-10 09:37:54Z mw $");
#endif
-__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.2 2018/05/19 09:32:55 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.3 2018/06/01 09:34:39 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1441,7 +1441,7 @@
rx_info, rx_info->mbuf, (uintmax_t)rx_info->ena_buf.paddr);
mbuf = rx_info->mbuf;
- mbuf->m_flags |= M_PKTHDR;
+ KASSERT(mbuf->m_flags & M_PKTHDR);
mbuf->m_pkthdr.len = len;
mbuf->m_len = len;
mbuf->m_pkthdr.rcvif = rx_ring->que->adapter->ifp;
Home |
Main Index |
Thread Index |
Old Index