netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.6.29.1 1/1] 8139too: fix HW initial flow
@ 2009-04-20 12:58 jon.lin
  2009-04-20 13:28 ` Amos Kong
  2009-04-21  8:52 ` David Miller
  0 siblings, 2 replies; 13+ messages in thread
From: jon.lin @ 2009-04-20 12:58 UTC (permalink / raw)
  To: davem; +Cc: dada1, netdev, linux-kernel, jon.lin

From: Jonathan Lin <jon.lin@vatics.com>

While ifconfig eth0 up kernel calls open() of 8139 driver(8139too.c).
In rtl8139_hw_start() of rtl8139_open(), 8139 driver enable RX before setting up the DMA buffer address. In this interval where RX was enabled and DMA buffer address is not yet set up, any incoming broadcast packet would be send to a strange physical address:
0x003e8800 which is the default value of DMA buffer address.
Unfortunately, this address is used by Linux kernel. So kernel panics.
This patch fix it by setting up DMA buffer address before RX enabled and everything is fine even under broadcast packets attack.

Signed-off-by: Jonathan Lin <jon.lin@vatics.com>

--- linux-2.6.29.1/drivers/net/8139too.c.orig   2009-04-19 17:50:38.000000000 +0800
+++ linux-2.6.29.1/drivers/net/8139too.c        2009-04-19 17:52:51.000000000 +0800
@@ -1382,6 +1382,10 @@ static void rtl8139_hw_start (struct net
        RTL_W32_F (MAC0 + 0, le32_to_cpu (*(__le32 *) (dev->dev_addr + 0)));
        RTL_W32_F (MAC0 + 4, le16_to_cpu (*(__le16 *) (dev->dev_addr + 4)));

+       tp->cur_rx = 0;
+       /* init Rx ring buffer DMA address BEFORE Rx enabled*/
+       RTL_W32_F (RxBuf, tp->rx_ring_dma);
+
        /* Must enable Tx/Rx before setting transfer thresholds! */
        RTL_W8 (ChipCmd, CmdRxEnb | CmdTxEnb);

@@ -1389,8 +1393,6 @@ static void rtl8139_hw_start (struct net
        RTL_W32 (RxConfig, tp->rx_config);
        RTL_W32 (TxConfig, rtl8139_tx_config);

-       tp->cur_rx = 0;
-
        rtl_check_media (dev, 1);

        if (tp->chipset >= CH_8139B) {
@@ -1405,9 +1407,6 @@ static void rtl8139_hw_start (struct net
        /* Lock Config[01234] and BMCR register writes */
        RTL_W8 (Cfg9346, Cfg9346_Lock);

-       /* init Rx ring buffer DMA address */
-       RTL_W32_F (RxBuf, tp->rx_ring_dma);
-
        /* init Tx buffer DMA addresses */
        for (i = 0; i < NUM_TX_DESC; i++)
                RTL_W32_F (TxAddr0 + (i * 4), tp->tx_bufs_dma + (tp->tx_buf[i] - tp->tx_bufs));

^ permalink raw reply	[flat|nested] 13+ messages in thread
* [PATCH 2.6.29.1 1/1]8139too:fix HW initial flow
@ 2009-04-21 10:13 User Tzungder
  0 siblings, 0 replies; 13+ messages in thread
From: User Tzungder @ 2009-04-21 10:13 UTC (permalink / raw)
  To: davem; +Cc: dada1, jon.lin, linux-kernel, netdev, tzungder

From:Jonathan Lin <jon.lin@vatics.com>

While ifconfig eth0 up kernel call open() of 8139 driver(8139too.c).
In rtl8139_hw_start() of rtl8139_open(), 8139 driver enable RX before setting up the DMA buffer address. In this interval where RX was enabled and DMA buffer address is not yet set up, any incoming broadcast packet would be send to a strange physical address: 0x003e8800 which is the default value of DMA buffer address.
Unfortunately, this address is used by Linux kernel. So kernel panics.
This patch fix it by setting up DMA buffer address before RX enabled and everything is fine even under broadcast packets attack.

Signed-off-by:Jonathan Lin <jon.lin@vatics.com>

--- linux-2.6.29.1/drivers/net/8139too.c.orig	2009-04-20 20:46:21.000000000 +0800
+++ linux-2.6.29.1/drivers/net/8139too.c	2009-04-20 20:58:39.000000000 +0800
@@ -1382,6 +1382,10 @@ static void rtl8139_hw_start (struct net
 	RTL_W32_F (MAC0 + 0, le32_to_cpu (*(__le32 *) (dev->dev_addr + 0)));
 	RTL_W32_F (MAC0 + 4, le16_to_cpu (*(__le16 *) (dev->dev_addr + 4)));
 
+	tp->cur_rx = 0;
+	/* init Rx ring buffer DMA address BEFORE Rx enabled*/
+	RTL_W32_F (RxBuf, tp->rx_ring_dma);
+	
 	/* Must enable Tx/Rx before setting transfer thresholds! */
 	RTL_W8 (ChipCmd, CmdRxEnb | CmdTxEnb);
 
@@ -1389,8 +1393,6 @@ static void rtl8139_hw_start (struct net
 	RTL_W32 (RxConfig, tp->rx_config);
 	RTL_W32 (TxConfig, rtl8139_tx_config);
 
-	tp->cur_rx = 0;
-
 	rtl_check_media (dev, 1);
 
 	if (tp->chipset >= CH_8139B) {
@@ -1405,9 +1407,6 @@ static void rtl8139_hw_start (struct net
 	/* Lock Config[01234] and BMCR register writes */
 	RTL_W8 (Cfg9346, Cfg9346_Lock);
 
-	/* init Rx ring buffer DMA address */
-	RTL_W32_F (RxBuf, tp->rx_ring_dma);
-
 	/* init Tx buffer DMA addresses */
 	for (i = 0; i < NUM_TX_DESC; i++)
 		RTL_W32_F (TxAddr0 + (i * 4), tp->tx_bufs_dma + (tp->tx_buf[i] - tp->tx_bufs));

^ permalink raw reply	[flat|nested] 13+ messages in thread
* [PATCH 2.6.29.1 1/1] 8139too: fix HW initial flow
@ 2009-04-19 10:16 Tzungder Lin
  2009-04-19 11:22 ` Eric Dumazet
  2009-04-20  1:54 ` Tzungder Lin
  0 siblings, 2 replies; 13+ messages in thread
From: Tzungder Lin @ 2009-04-19 10:16 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev, davem, linux-kernel

From: Jonathan Lin <jon.lin@vatics.com, tzungder@gmail.com>

While ifconfig eth0 up kernel calls open() of 8139 driver(8139too.c).
In rtl8139_hw_start() of rtl8139_open(), 8139 driver enable RX before
setting up the DMA buffer address. In this interval where RX was
enabled and DMA buffer address is not yet set up, any incoming
broadcast packet would be send to a strange physical address:
0x003e8800 which is the default value of DMA buffer address.
Unfortunately, this address is used by Linux kernel. So kernel panics.
This patch fix it by setting up DMA buffer address before RX enabled
and everything is fine even under broadcast packets attack.

Signed-off-by: Jonathan Lin <jon.lin@vatics.com, tzungder@gmail.com>

---

--- linux-2.6.29.1/drivers/net/8139too.c.orig	2009-04-19
17:50:38.000000000 +0800
+++ linux-2.6.29.1/drivers/net/8139too.c	2009-04-19 17:52:51.000000000 +0800
@@ -1382,6 +1382,10 @@ static void rtl8139_hw_start (struct net
 	RTL_W32_F (MAC0 + 0, le32_to_cpu (*(__le32 *) (dev->dev_addr + 0)));
 	RTL_W32_F (MAC0 + 4, le16_to_cpu (*(__le16 *) (dev->dev_addr + 4)));

+	tp->cur_rx = 0;
+	/* init Rx ring buffer DMA address BEFORE Rx enabled*/
+	RTL_W32_F (RxBuf, tp->rx_ring_dma);
+	
 	/* Must enable Tx/Rx before setting transfer thresholds! */
 	RTL_W8 (ChipCmd, CmdRxEnb | CmdTxEnb);

@@ -1389,8 +1393,6 @@ static void rtl8139_hw_start (struct net
 	RTL_W32 (RxConfig, tp->rx_config);
 	RTL_W32 (TxConfig, rtl8139_tx_config);

-	tp->cur_rx = 0;
-
 	rtl_check_media (dev, 1);

 	if (tp->chipset >= CH_8139B) {
@@ -1405,9 +1407,6 @@ static void rtl8139_hw_start (struct net
 	/* Lock Config[01234] and BMCR register writes */
 	RTL_W8 (Cfg9346, Cfg9346_Lock);

-	/* init Rx ring buffer DMA address */
-	RTL_W32_F (RxBuf, tp->rx_ring_dma);
-
 	/* init Tx buffer DMA addresses */
 	for (i = 0; i < NUM_TX_DESC; i++)
 		RTL_W32_F (TxAddr0 + (i * 4), tp->tx_bufs_dma + (tp->tx_buf[i] -
tp->tx_bufs));

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2009-04-22  7:44 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-20 12:58 [PATCH 2.6.29.1 1/1] 8139too: fix HW initial flow jon.lin
2009-04-20 13:28 ` Amos Kong
2009-04-21  8:52 ` David Miller
2009-04-21  9:48   ` Amos Kong
2009-04-21 10:09     ` jon.lin
2009-04-21 10:34       ` Eric Dumazet
2009-04-21 10:30     ` Eric Dumazet
2009-04-22  7:44       ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2009-04-21 10:13 [PATCH 2.6.29.1 1/1]8139too:fix " User Tzungder
2009-04-19 10:16 [PATCH 2.6.29.1 1/1] 8139too: fix " Tzungder Lin
2009-04-19 11:22 ` Eric Dumazet
2009-04-20  1:54 ` Tzungder Lin
2009-04-20 10:14   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).