* [PATCH] irda: fix a race in irlan_eth_xmit()
@ 2010-08-18 10:24 Eric Dumazet
2010-08-19 7:42 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2010-08-18 10:24 UTC (permalink / raw)
To: David Miller; +Cc: Samuel Ortiz, netdev
After skb is queued, its illegal to dereference it.
Cache skb->len into a temporary variable.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
net/irda/irlan/irlan_eth.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/irda/irlan/irlan_eth.c b/net/irda/irlan/irlan_eth.c
index 9616c32..5bb8353 100644
--- a/net/irda/irlan/irlan_eth.c
+++ b/net/irda/irlan/irlan_eth.c
@@ -169,6 +169,7 @@ static netdev_tx_t irlan_eth_xmit(struct sk_buff *skb,
{
struct irlan_cb *self = netdev_priv(dev);
int ret;
+ unsigned int len;
/* skb headroom large enough to contain all IrDA-headers? */
if ((skb_headroom(skb) < self->max_header_size) || (skb_shared(skb))) {
@@ -188,6 +189,7 @@ static netdev_tx_t irlan_eth_xmit(struct sk_buff *skb,
dev->trans_start = jiffies;
+ len = skb->len;
/* Now queue the packet in the transport layer */
if (self->use_udata)
ret = irttp_udata_request(self->tsap_data, skb);
@@ -209,7 +211,7 @@ static netdev_tx_t irlan_eth_xmit(struct sk_buff *skb,
self->stats.tx_dropped++;
} else {
self->stats.tx_packets++;
- self->stats.tx_bytes += skb->len;
+ self->stats.tx_bytes += len;
}
return NETDEV_TX_OK;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] irda: fix a race in irlan_eth_xmit()
2010-08-18 10:24 [PATCH] irda: fix a race in irlan_eth_xmit() Eric Dumazet
@ 2010-08-19 7:42 ` David Miller
2010-08-20 9:51 ` Eric Dumazet
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2010-08-19 7:42 UTC (permalink / raw)
To: eric.dumazet; +Cc: samuel, netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 18 Aug 2010 12:24:43 +0200
> After skb is queued, its illegal to dereference it.
>
> Cache skb->len into a temporary variable.
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] irda: fix a race in irlan_eth_xmit()
2010-08-19 7:42 ` David Miller
@ 2010-08-20 9:51 ` Eric Dumazet
2010-08-22 7:09 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2010-08-20 9:51 UTC (permalink / raw)
To: David Miller; +Cc: samuel, netdev
Le jeudi 19 août 2010 à 00:42 -0700, David Miller a écrit :
> From: Eric Dumazet <eric.dumazet@gmail.com>
> Date: Wed, 18 Aug 2010 12:24:43 +0200
>
> > After skb is queued, its illegal to dereference it.
> >
> > Cache skb->len into a temporary variable.
> >
> > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
>
> Applied, thanks.
Thanks David
On top of this patch (that you added in net-2.6 if I understood well), I
cooked following one, for net-next-2.6 this time.
[PATCH net-next-2.6] irda: use net_device_stats from struct net_device
struct net_device has its own struct net_device_stats member, so use
this one instead of a private copy in the irlan_cb struct.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
include/net/irda/irlan_common.h | 1
net/irda/irlan/irlan_eth.c | 32 ++++++++----------------------
2 files changed, 9 insertions(+), 24 deletions(-)
diff --git a/include/net/irda/irlan_common.h b/include/net/irda/irlan_common.h
index 73cacb3..0af8b8d 100644
--- a/include/net/irda/irlan_common.h
+++ b/include/net/irda/irlan_common.h
@@ -171,7 +171,6 @@ struct irlan_cb {
int magic;
struct list_head dev_list;
struct net_device *dev; /* Ethernet device structure*/
- struct net_device_stats stats;
__u32 saddr; /* Source device address */
__u32 daddr; /* Destination device address */
diff --git a/net/irda/irlan/irlan_eth.c b/net/irda/irlan/irlan_eth.c
index 5bb8353..8ee1ff6 100644
--- a/net/irda/irlan/irlan_eth.c
+++ b/net/irda/irlan/irlan_eth.c
@@ -45,13 +45,11 @@ static int irlan_eth_close(struct net_device *dev);
static netdev_tx_t irlan_eth_xmit(struct sk_buff *skb,
struct net_device *dev);
static void irlan_eth_set_multicast_list( struct net_device *dev);
-static struct net_device_stats *irlan_eth_get_stats(struct net_device *dev);
static const struct net_device_ops irlan_eth_netdev_ops = {
.ndo_open = irlan_eth_open,
.ndo_stop = irlan_eth_close,
.ndo_start_xmit = irlan_eth_xmit,
- .ndo_get_stats = irlan_eth_get_stats,
.ndo_set_multicast_list = irlan_eth_set_multicast_list,
.ndo_change_mtu = eth_change_mtu,
.ndo_validate_addr = eth_validate_addr,
@@ -208,10 +206,10 @@ static netdev_tx_t irlan_eth_xmit(struct sk_buff *skb,
* tried :-) DB
*/
/* irttp_data_request already free the packet */
- self->stats.tx_dropped++;
+ dev->stats.tx_dropped++;
} else {
- self->stats.tx_packets++;
- self->stats.tx_bytes += len;
+ dev->stats.tx_packets++;
+ dev->stats.tx_bytes += len;
}
return NETDEV_TX_OK;
@@ -226,15 +224,16 @@ static netdev_tx_t irlan_eth_xmit(struct sk_buff *skb,
int irlan_eth_receive(void *instance, void *sap, struct sk_buff *skb)
{
struct irlan_cb *self = instance;
+ struct net_device *dev = self->dev;
if (skb == NULL) {
- ++self->stats.rx_dropped;
+ dev->stats.rx_dropped++;
return 0;
}
if (skb->len < ETH_HLEN) {
IRDA_DEBUG(0, "%s() : IrLAN frame too short (%d)\n",
__func__, skb->len);
- ++self->stats.rx_dropped;
+ dev->stats.rx_dropped++;
dev_kfree_skb(skb);
return 0;
}
@@ -244,10 +243,10 @@ int irlan_eth_receive(void *instance, void *sap, struct sk_buff *skb)
* might have been previously set by the low level IrDA network
* device driver
*/
- skb->protocol = eth_type_trans(skb, self->dev); /* Remove eth header */
+ skb->protocol = eth_type_trans(skb, dev); /* Remove eth header */
- self->stats.rx_packets++;
- self->stats.rx_bytes += skb->len;
+ dev->stats.rx_packets++;
+ dev->stats.rx_bytes += skb->len;
netif_rx(skb); /* Eat it! */
@@ -348,16 +347,3 @@ static void irlan_eth_set_multicast_list(struct net_device *dev)
else
irlan_set_broadcast_filter(self, FALSE);
}
-
-/*
- * Function irlan_get_stats (dev)
- *
- * Get the current statistics for this device
- *
- */
-static struct net_device_stats *irlan_eth_get_stats(struct net_device *dev)
-{
- struct irlan_cb *self = netdev_priv(dev);
-
- return &self->stats;
-}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] irda: fix a race in irlan_eth_xmit()
2010-08-20 9:51 ` Eric Dumazet
@ 2010-08-22 7:09 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2010-08-22 7:09 UTC (permalink / raw)
To: eric.dumazet; +Cc: samuel, netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 20 Aug 2010 11:51:33 +0200
> [PATCH net-next-2.6] irda: use net_device_stats from struct net_device
>
> struct net_device has its own struct net_device_stats member, so use
> this one instead of a private copy in the irlan_cb struct.
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-08-22 7:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-18 10:24 [PATCH] irda: fix a race in irlan_eth_xmit() Eric Dumazet
2010-08-19 7:42 ` David Miller
2010-08-20 9:51 ` Eric Dumazet
2010-08-22 7:09 ` 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).