diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-03-19 00:16:45 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-03-19 00:16:45 -0400 |
commit | 0641e4fbf2f824faee00ea74c459a088d94905fd (patch) | |
tree | 54fdd8bc2e3a928ff0f7621c06e1e604eaf0529c /net/core/dev.c | |
parent | 54d259d474e1fee6f6bb8f0f1360d85195199ac5 (diff) |
net: Potential null skb->dev dereference
When doing "ifenslave -d bond0 eth0", there is chance to get NULL
dereference in netif_receive_skb(), because dev->master suddenly becomes
NULL after we tested it.
We should use ACCESS_ONCE() to avoid this (or rcu_dereference())
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r-- | net/core/dev.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index bcc490cc9452..59d4394d2ce8 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -2483,6 +2483,7 @@ int netif_receive_skb(struct sk_buff *skb) | |||
2483 | { | 2483 | { |
2484 | struct packet_type *ptype, *pt_prev; | 2484 | struct packet_type *ptype, *pt_prev; |
2485 | struct net_device *orig_dev; | 2485 | struct net_device *orig_dev; |
2486 | struct net_device *master; | ||
2486 | struct net_device *null_or_orig; | 2487 | struct net_device *null_or_orig; |
2487 | struct net_device *null_or_bond; | 2488 | struct net_device *null_or_bond; |
2488 | int ret = NET_RX_DROP; | 2489 | int ret = NET_RX_DROP; |
@@ -2503,11 +2504,12 @@ int netif_receive_skb(struct sk_buff *skb) | |||
2503 | 2504 | ||
2504 | null_or_orig = NULL; | 2505 | null_or_orig = NULL; |
2505 | orig_dev = skb->dev; | 2506 | orig_dev = skb->dev; |
2506 | if (orig_dev->master) { | 2507 | master = ACCESS_ONCE(orig_dev->master); |
2507 | if (skb_bond_should_drop(skb)) | 2508 | if (master) { |
2509 | if (skb_bond_should_drop(skb, master)) | ||
2508 | null_or_orig = orig_dev; /* deliver only exact match */ | 2510 | null_or_orig = orig_dev; /* deliver only exact match */ |
2509 | else | 2511 | else |
2510 | skb->dev = orig_dev->master; | 2512 | skb->dev = master; |
2511 | } | 2513 | } |
2512 | 2514 | ||
2513 | __get_cpu_var(netdev_rx_stat).total++; | 2515 | __get_cpu_var(netdev_rx_stat).total++; |