diff options
author | Amerigo Wang <amwang@redhat.com> | 2012-08-09 21:24:40 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-08-14 17:33:31 -0400 |
commit | 57c5d46191e75312934c00eba65b13a31ca95120 (patch) | |
tree | 18eb9488b414f0dacdf7be468985a29ceeb1f2e9 | |
parent | 3335f0ca130c201f8680e97f63612053fbc16e22 (diff) |
netpoll: take rcu_read_lock_bh() in netpoll_rx()
In __netpoll_rx(), it dereferences ->npinfo without rcu_dereference_bh(),
this patch fixes it by using the 'npinfo' passed from netpoll_rx()
where it is already dereferenced with rcu_dereference_bh().
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/netpoll.h | 4 | ||||
-rw-r--r-- | net/core/netpoll.c | 3 |
2 files changed, 3 insertions, 4 deletions
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index 907812efb4d9..5d881c388273 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h | |||
@@ -52,7 +52,7 @@ void netpoll_set_trap(int trap); | |||
52 | void __netpoll_cleanup(struct netpoll *np); | 52 | void __netpoll_cleanup(struct netpoll *np); |
53 | void __netpoll_free_rcu(struct netpoll *np); | 53 | void __netpoll_free_rcu(struct netpoll *np); |
54 | void netpoll_cleanup(struct netpoll *np); | 54 | void netpoll_cleanup(struct netpoll *np); |
55 | int __netpoll_rx(struct sk_buff *skb); | 55 | int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo); |
56 | void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb, | 56 | void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb, |
57 | struct net_device *dev); | 57 | struct net_device *dev); |
58 | static inline void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) | 58 | static inline void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) |
@@ -77,7 +77,7 @@ static inline bool netpoll_rx(struct sk_buff *skb) | |||
77 | 77 | ||
78 | spin_lock(&npinfo->rx_lock); | 78 | spin_lock(&npinfo->rx_lock); |
79 | /* check rx_flags again with the lock held */ | 79 | /* check rx_flags again with the lock held */ |
80 | if (npinfo->rx_flags && __netpoll_rx(skb)) | 80 | if (npinfo->rx_flags && __netpoll_rx(skb, npinfo)) |
81 | ret = true; | 81 | ret = true; |
82 | spin_unlock(&npinfo->rx_lock); | 82 | spin_unlock(&npinfo->rx_lock); |
83 | 83 | ||
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index dc17f1db1479..d055bb01328b 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c | |||
@@ -543,13 +543,12 @@ static void arp_reply(struct sk_buff *skb) | |||
543 | spin_unlock_irqrestore(&npinfo->rx_lock, flags); | 543 | spin_unlock_irqrestore(&npinfo->rx_lock, flags); |
544 | } | 544 | } |
545 | 545 | ||
546 | int __netpoll_rx(struct sk_buff *skb) | 546 | int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo) |
547 | { | 547 | { |
548 | int proto, len, ulen; | 548 | int proto, len, ulen; |
549 | int hits = 0; | 549 | int hits = 0; |
550 | const struct iphdr *iph; | 550 | const struct iphdr *iph; |
551 | struct udphdr *uh; | 551 | struct udphdr *uh; |
552 | struct netpoll_info *npinfo = skb->dev->npinfo; | ||
553 | struct netpoll *np, *tmp; | 552 | struct netpoll *np, *tmp; |
554 | 553 | ||
555 | if (list_empty(&npinfo->rx_np)) | 554 | if (list_empty(&npinfo->rx_np)) |