diff options
author | David S. Miller <davem@davemloft.net> | 2008-02-12 00:45:44 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-02-12 20:54:17 -0500 |
commit | 69cc64d8d92bf852f933e90c888dfff083bd4fc9 (patch) | |
tree | 33e3b7c690fc1b0658cd64dac3d8c3ef7e7bb71f /net/core | |
parent | 3611f4d2a5e0f6135805f88bc5ecb63fa9ee5107 (diff) |
[NDISC]: Fix race in generic address resolution
Frank Blaschka provided the bug report and the initial suggested fix
for this bug. He also validated this version of this fix.
The problem is that the access to neigh->arp_queue is inconsistent, we
grab references when dropping the lock lock to call
neigh->ops->solicit() but this does not prevent other threads of
control from trying to send out that packet at the same time causing
corruptions because both code paths believe they have exclusive access
to the skb.
The best option seems to be to hold the write lock on neigh->lock
during the ->solicit() call. I looked at all of the ndisc_ops
implementations and this seems workable. The only case that needs
special care is the IPV4 ARP implementation of arp_solicit(). It
wants to take neigh->lock as a reader to protect the header entry in
neigh->ha during the emission of the soliciation. We can simply
remove the read lock calls to take care of that since holding the lock
as a writer at the caller providers a superset of the protection
afforded by the existing read locking.
The rest of the ->solicit() implementations don't care whether the
neigh is locked or not.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/neighbour.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index a16cf1ec5e5e..7bb6a9a1256d 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -834,18 +834,12 @@ static void neigh_timer_handler(unsigned long arg) | |||
834 | } | 834 | } |
835 | if (neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) { | 835 | if (neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) { |
836 | struct sk_buff *skb = skb_peek(&neigh->arp_queue); | 836 | struct sk_buff *skb = skb_peek(&neigh->arp_queue); |
837 | /* keep skb alive even if arp_queue overflows */ | 837 | |
838 | if (skb) | ||
839 | skb_get(skb); | ||
840 | write_unlock(&neigh->lock); | ||
841 | neigh->ops->solicit(neigh, skb); | 838 | neigh->ops->solicit(neigh, skb); |
842 | atomic_inc(&neigh->probes); | 839 | atomic_inc(&neigh->probes); |
843 | if (skb) | ||
844 | kfree_skb(skb); | ||
845 | } else { | ||
846 | out: | ||
847 | write_unlock(&neigh->lock); | ||
848 | } | 840 | } |
841 | out: | ||
842 | write_unlock(&neigh->lock); | ||
849 | 843 | ||
850 | if (notify) | 844 | if (notify) |
851 | neigh_update_notify(neigh); | 845 | neigh_update_notify(neigh); |