Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jun 2021 05:53:02 GMT
From:      Alex Dupre <ale@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: c83bb257d1cd - main - net/realtek-re-kmod: fix locking bugs.
Message-ID:  <202106220553.15M5r2Tf002151@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by ale:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c83bb257d1cd80e1627375a1875a0764b059620e

commit c83bb257d1cd80e1627375a1875a0764b059620e
Author:     Alex Dupre <ale@FreeBSD.org>
AuthorDate: 2021-06-22 05:51:09 +0000
Commit:     Alex Dupre <ale@FreeBSD.org>
CommitDate: 2021-06-22 05:52:49 +0000

    net/realtek-re-kmod: fix locking bugs.
    
    PR:             256757
    Submitted by:   Niels Bakker <niels=freebsd@bakker.net>
---
 net/realtek-re-kmod/Makefile             |   2 +-
 net/realtek-re-kmod/files/patch-if__re.c | 121 ++++++++++++++++++++++++++++---
 2 files changed, 113 insertions(+), 10 deletions(-)

diff --git a/net/realtek-re-kmod/Makefile b/net/realtek-re-kmod/Makefile
index 29d292213cbf..27d6904c57c1 100644
--- a/net/realtek-re-kmod/Makefile
+++ b/net/realtek-re-kmod/Makefile
@@ -2,7 +2,7 @@
 
 PORTNAME=	re
 DISTVERSION=	v196.04
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	net
 MASTER_SITES=	LOCAL/ale
 PKGNAMEPREFIX=	realtek-
diff --git a/net/realtek-re-kmod/files/patch-if__re.c b/net/realtek-re-kmod/files/patch-if__re.c
index 82e11185f319..c8ee0e047037 100644
--- a/net/realtek-re-kmod/files/patch-if__re.c
+++ b/net/realtek-re-kmod/files/patch-if__re.c
@@ -76,7 +76,35 @@
  
  #define RE_CSUM_FEATURES    (CSUM_IP | CSUM_TCP | CSUM_UDP)
  
-@@ -3428,16 +3442,6 @@ is_valid_ether_addr(const u_int8_t * addr)
+@@ -930,6 +944,7 @@ static int re_alloc_buf(struct re_softc *sc)
+         int error =0;
+         int i,size;
+ 
++	RE_UNLOCK(sc);
+         error = bus_dma_tag_create(sc->re_parent_tag, 1, 0,
+                                    BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL,
+                                    NULL, MCLBYTES* RE_NTXSEGS, RE_NTXSEGS, 4096, 0,
+@@ -938,6 +953,7 @@ static int re_alloc_buf(struct re_softc *sc)
+         if (error) {
+                 //device_printf(dev,"re_tx_mtag fail\n");
+                 //goto fail;
++		RE_LOCK(sc);
+                 return error;
+         }
+ 
+@@ -955,9 +971,11 @@ static int re_alloc_buf(struct re_softc *sc)
+         if (error) {
+                 //device_printf(dev,"re_rx_mtag fail\n");
+                 //goto fail;
++		RE_LOCK(sc);
+                 return error;
+         }
+ 
++	RE_LOCK(sc);
+         if (sc->re_rx_mbuf_sz <= MCLBYTES)
+                 size = MCLBYTES;
+         else if (sc->re_rx_mbuf_sz <=  MJUMPAGESIZE)
+@@ -3428,16 +3446,6 @@ is_valid_ether_addr(const u_int8_t * addr)
          return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr);
  }
  
@@ -93,7 +121,7 @@
  static void re_disable_now_is_oob(struct re_softc *sc)
  {
          if (sc->re_hw_supp_now_is_oob_ver == 1)
-@@ -3889,7 +3893,7 @@ static void re_get_hw_mac_address(struct re_softc *sc,
+@@ -3889,7 +3897,7 @@ static void re_get_hw_mac_address(struct re_softc *sc,
  
          if (!is_valid_ether_addr(eaddr)) {
                  device_printf(dev,"Invalid ether addr: %6D\n", eaddr, ":");
@@ -102,7 +130,7 @@
                  device_printf(dev,"Random ether addr: %6D\n", eaddr, ":");
          }
  
-@@ -4291,9 +4295,9 @@ static void re_init_software_variable(struct re_softc 
+@@ -4291,9 +4299,9 @@ static void re_init_software_variable(struct re_softc 
  
          sc->re_rx_mbuf_sz = sc->max_jumbo_frame_size + ETHER_VLAN_ENCAP_LEN + ETHER_HDR_LEN + ETHER_CRC_LEN + RE_ETHER_ALIGN + 1;
  
@@ -115,7 +143,63 @@
          }
  
          switch(sc->re_type) {
-@@ -8614,6 +8618,22 @@ struct re_softc		*sc;
+@@ -7073,12 +7081,11 @@ static void re_init_unlock(void *xsc)  	/* Software & 
+         return;
+ }
+ 
+-static void re_init(void *xsc)  	/* Software & Hardware Initialize */
++static void re_init_locked(void *xsc)
+ {
+         struct re_softc		*sc = xsc;
+         struct ifnet		*ifp;
+ 
+-        RE_LOCK(sc);
+         ifp = RE_GET_IFNET(sc);
+ 
+         if (re_link_ok(sc)) {
+@@ -7089,7 +7096,14 @@ static void re_init(void *xsc)  	/* Software & Hardwar
+ 
+         sc->re_link_chg_det = 1;
+         re_start_timer(sc);
++}
+ 
++static void re_init(void *xsc)  	/* Software & Hardware Initialize */
++{
++        struct re_softc		*sc = xsc;
++
++        RE_LOCK(sc);
++	re_init_locked(sc);
+         RE_UNLOCK(sc);
+ }
+ 
+@@ -8438,7 +8452,7 @@ static void re_int_task(void *arg, int npending)
+                         if ((status & RE_ISR_FIFO_OFLOW) &&
+                             (!(status & (RE_ISR_RX_OK | RE_ISR_TX_OK | RE_ISR_RX_OVERRUN)))) {
+                                 re_reset(sc);
+-                                re_init(sc);
++                                re_init_locked(sc);
+                                 sc->rx_fifo_overflow = 0;
+                                 CSR_WRITE_2(sc, RE_ISR, RE_ISR_FIFO_OFLOW);
+                         }
+@@ -8449,7 +8463,7 @@ static void re_int_task(void *arg, int npending)
+ 
+         if (status & RE_ISR_SYSTEM_ERR) {
+                 re_reset(sc);
+-                re_init(sc);
++                re_init_locked(sc);
+         }
+ 
+         switch(sc->re_type) {
+@@ -8514,7 +8528,7 @@ static void re_int_task_8125(void *arg, int npending)
+ 
+         if (status & RE_ISR_SYSTEM_ERR) {
+                 re_reset(sc);
+-                re_init(sc);
++                re_init_locked(sc);
+         }
+ 
+         RE_UNLOCK(sc);
+@@ -8614,6 +8628,22 @@ struct re_softc		*sc;
          return;
  }
  
@@ -138,7 +222,7 @@
  /*
   * Program the 64-bit multicast hash filter.
   */
-@@ -8623,7 +8643,9 @@ struct re_softc		*sc;
+@@ -8623,7 +8653,9 @@ struct re_softc		*sc;
          struct ifnet		*ifp;
          int			h = 0;
          u_int32_t		hashes[2] = { 0, 0 };
@@ -148,13 +232,13 @@
          u_int32_t		rxfilt;
          int			mcnt = 0;
  
-@@ -8640,7 +8662,12 @@ struct re_softc		*sc;
+@@ -8640,7 +8672,12 @@ struct re_softc		*sc;
          }
  
          /* now program new ones */
 -#if OS_VER > VERSION(6,0)
 +#if OS_VER >= VERSION(13,0)
-+	if_foreach_llmaddr(ifp, re_hash_maddr, hashes);
++	mcnt = if_foreach_llmaddr(ifp, re_hash_maddr, hashes);
 +#else
 +#if OS_VER >= VERSION(12,0)
 +	if_maddr_rlock(ifp);
@@ -162,7 +246,7 @@
          IF_ADDR_LOCK(ifp);
  #endif
  #if OS_VER < VERSION(4,9)
-@@ -8662,8 +8689,11 @@ struct re_softc		*sc;
+@@ -8662,9 +8699,12 @@ struct re_softc		*sc;
                          hashes[1] |= (1 << (h - 32));
                  mcnt++;
          }
@@ -171,7 +255,26 @@
 +	if_maddr_runlock(ifp);
 +#elif OS_VER > VERSION(6,0)
          IF_ADDR_UNLOCK(ifp);
-+#endif
  #endif
++#endif
  
          if (mcnt) {
+                 if ((sc->re_if_flags & RL_FLAG_PCIE) != 0) {
+@@ -8720,7 +8760,7 @@ caddr_t			data;
+                                 error =re_alloc_buf(sc);
+ 
+                                 if (error == 0) {
+-                                        re_init(sc);
++                                        re_init_locked(sc);
+                                 }
+                                 RE_UNLOCK(sc);
+ 
+@@ -8743,7 +8783,7 @@ caddr_t			data;
+         case SIOCSIFFLAGS:
+                 RE_LOCK(sc);
+                 if (ifp->if_flags & IFF_UP) {
+-                        re_init(sc);
++                        re_init_locked(sc);
+                 } else if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+                         re_stop(sc);
+                 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106220553.15M5r2Tf002151>