public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Joe Jin <joe.jin@oracle.com>,
	Eric Dumazet <edumazet@google.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [ 04/79] neighbour: fix a race in neigh_destroy()
Date: Fri, 26 Jul 2013 13:46:54 -0700	[thread overview]
Message-ID: <20130726204722.376058298@linuxfoundation.org> (raw)
In-Reply-To: <20130726204721.849052763@linuxfoundation.org>

3.10-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <eric.dumazet@gmail.com>

[ Upstream commit c9ab4d85de222f3390c67aedc9c18a50e767531e ]

There is a race in neighbour code, because neigh_destroy() uses
skb_queue_purge(&neigh->arp_queue) without holding neighbour lock,
while other parts of the code assume neighbour rwlock is what
protects arp_queue

Convert all skb_queue_purge() calls to the __skb_queue_purge() variant

Use __skb_queue_head_init() instead of skb_queue_head_init()
to make clear we do not use arp_queue.lock

And hold neigh->lock in neigh_destroy() to close the race.

Reported-by: Joe Jin <joe.jin@oracle.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/core/neighbour.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -231,7 +231,7 @@ static void neigh_flush_dev(struct neigh
 				   we must kill timers etc. and move
 				   it to safe state.
 				 */
-				skb_queue_purge(&n->arp_queue);
+				__skb_queue_purge(&n->arp_queue);
 				n->arp_queue_len_bytes = 0;
 				n->output = neigh_blackhole;
 				if (n->nud_state & NUD_VALID)
@@ -286,7 +286,7 @@ static struct neighbour *neigh_alloc(str
 	if (!n)
 		goto out_entries;
 
-	skb_queue_head_init(&n->arp_queue);
+	__skb_queue_head_init(&n->arp_queue);
 	rwlock_init(&n->lock);
 	seqlock_init(&n->ha_lock);
 	n->updated	  = n->used = now;
@@ -708,7 +708,9 @@ void neigh_destroy(struct neighbour *nei
 	if (neigh_del_timer(neigh))
 		pr_warn("Impossible event\n");
 
-	skb_queue_purge(&neigh->arp_queue);
+	write_lock_bh(&neigh->lock);
+	__skb_queue_purge(&neigh->arp_queue);
+	write_unlock_bh(&neigh->lock);
 	neigh->arp_queue_len_bytes = 0;
 
 	if (dev->netdev_ops->ndo_neigh_destroy)
@@ -858,7 +860,7 @@ static void neigh_invalidate(struct neig
 		neigh->ops->error_report(neigh, skb);
 		write_lock(&neigh->lock);
 	}
-	skb_queue_purge(&neigh->arp_queue);
+	__skb_queue_purge(&neigh->arp_queue);
 	neigh->arp_queue_len_bytes = 0;
 }
 
@@ -1210,7 +1212,7 @@ int neigh_update(struct neighbour *neigh
 
 			write_lock_bh(&neigh->lock);
 		}
-		skb_queue_purge(&neigh->arp_queue);
+		__skb_queue_purge(&neigh->arp_queue);
 		neigh->arp_queue_len_bytes = 0;
 	}
 out:



  parent reply	other threads:[~2013-07-26 20:46 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-26 20:46 [ 00/79] 3.10.4-stable review Greg Kroah-Hartman
2013-07-26 20:46 ` [ 01/79] writeback: Fix periodic writeback after fs mount Greg Kroah-Hartman
2013-07-26 20:46 ` [ 02/79] sparc32: vm_area_struct access for old Sun SPARCs Greg Kroah-Hartman
2013-07-27 15:39   ` Ben Hutchings
2013-07-26 20:46 ` [ 03/79] ipv6: only apply anti-spoofing checks to not-pointopoint tunnels Greg Kroah-Hartman
2013-07-26 20:46 ` Greg Kroah-Hartman [this message]
2013-07-26 20:46 ` [ 05/79] x25: Fix broken locking in ioctl error paths Greg Kroah-Hartman
2013-07-26 20:46 ` [ 06/79] net: Swap ver and type in pppoe_hdr Greg Kroah-Hartman
2013-07-27 15:58   ` Ben Hutchings
2013-07-28  0:55     ` David Miller
2013-07-28  3:14       ` Ben Hutchings
2013-07-28  4:16         ` Greg KH
2013-07-28  4:39           ` David Miller
2013-07-28 18:29             ` Greg KH
2013-07-26 20:46 ` [ 07/79] gre: fix a regression in ioctl Greg Kroah-Hartman
2013-07-26 20:46 ` [ 08/79] vti: remove duplicated code to fix a memory leak Greg Kroah-Hartman
2013-07-26 20:46 ` [ 09/79] ipv6,mcast: always hold idev->lock before mca_lock Greg Kroah-Hartman
2013-07-26 20:47 ` [ 10/79] ip_tunnels: Use skb-len to PMTU check Greg Kroah-Hartman
2013-07-26 20:47 ` [ 11/79] l2tp: add missing .owner to struct pppox_proto Greg Kroah-Hartman
2013-07-26 20:47 ` [ 12/79] ipip: fix a regression in ioctl Greg Kroah-Hartman
2013-07-26 20:47 ` [ 13/79] ipv6: call udp_push_pending_frames when uncorking a socket with AF_INET pending data Greg Kroah-Hartman
2013-07-26 20:47 ` [ 14/79] ipv6: ip6_append_data_mtu did not care about pmtudisc and frag_size Greg Kroah-Hartman
2013-07-26 20:47 ` [ 15/79] ipv6: rt6_check_neigh should successfully verify neigh if no NUD information are available Greg Kroah-Hartman
2013-07-26 20:47 ` [ 16/79] sfc: Fix memory leak when discarding scattered packets Greg Kroah-Hartman
2013-07-26 20:47 ` [ 17/79] net/cadence/macb: fix bug/typo in extracting gem_irq_read_clear bit Greg Kroah-Hartman
2013-07-26 20:47 ` [ 18/79] virtio: support unlocked queue poll Greg Kroah-Hartman
2013-07-26 20:47 ` [ 19/79] virtio_net: fix race in RX VQ processing Greg Kroah-Hartman
2013-07-26 20:47 ` [ 20/79] vhost-net: fix use-after-free in vhost_net_flush Greg Kroah-Hartman
2013-07-26 20:47 ` [ 21/79] sunvnet: vnet_port_remove must call unregister_netdev Greg Kroah-Hartman
2013-07-26 20:47 ` [ 22/79] ifb: fix rcu_sched self-detected stalls Greg Kroah-Hartman
2013-07-26 20:47 ` [ 23/79] tuntap: correctly linearize skb when zerocopy is used Greg Kroah-Hartman
2013-07-26 20:47 ` [ 24/79] macvtap: " Greg Kroah-Hartman
2013-07-26 20:47 ` [ 25/79] ipv6: in case of link failure remove route directly instead of letting it expire Greg Kroah-Hartman
2013-07-26 20:47 ` [ 26/79] 9p: fix off by one causing access violations and memory corruption Greg Kroah-Hartman
2013-07-26 20:47 ` [ 27/79] alx: fix lockdep annotation Greg Kroah-Hartman
2013-07-26 20:47 ` [ 28/79] ipv6: fix route selection if kernel is not compiled with CONFIG_IPV6_ROUTER_PREF Greg Kroah-Hartman
2013-07-26 20:47 ` [ 29/79] dummy: fix oops when loading the dummy failed Greg Kroah-Hartman
2013-07-26 20:47 ` [ 30/79] ifb: fix oops when loading the ifb failed Greg Kroah-Hartman
2013-07-26 20:47 ` [ 31/79] gre: Fix MTU sizing check for gretap tunnels Greg Kroah-Hartman
2013-07-26 20:47 ` [ 32/79] ipv6: only static routes qualify for equal cost multipathing Greg Kroah-Hartman
2013-07-26 20:47 ` [ 33/79] atl1e: fix dma mapping warnings Greg Kroah-Hartman
2013-07-26 20:47 ` [ 34/79] atl1e: unmap partially mapped skb on dma error and free skb Greg Kroah-Hartman
2013-07-26 20:47 ` [ 35/79] ipv4: set transport header earlier Greg Kroah-Hartman
2013-07-26 20:47 ` [ 36/79] be2net: Fix to avoid hardware workaround when not needed Greg Kroah-Hartman
2013-07-26 20:47 ` [ 37/79] hyperv: Fix the NETIF_F_SG flag setting in netvsc Greg Kroah-Hartman
2013-07-26 20:47 ` [ 38/79] pkt_sched: sch_qfq: remove a source of high packet delay/jitter Greg Kroah-Hartman
2013-07-26 20:47 ` [ 39/79] tuntap: do not zerocopy if iov needs more pages than MAX_SKB_FRAGS Greg Kroah-Hartman
2013-07-26 20:47 ` [ 40/79] macvtap: " Greg Kroah-Hartman
2013-07-26 20:47 ` [ 41/79] vlan: mask vlan prio bits Greg Kroah-Hartman
2013-07-26 20:47 ` [ 42/79] vlan: fix a race in egress prio management Greg Kroah-Hartman
2013-07-27 16:55   ` Ben Hutchings
2013-07-27 17:38     ` Eric Dumazet
2013-07-27 17:58       ` Ben Hutchings
2013-07-26 20:47 ` [ 43/79] MIPS: Oceton: Fix build error Greg Kroah-Hartman
2013-07-26 20:47 ` [ 44/79] RAPIDIO: IDT_GEN2: " Greg Kroah-Hartman
2013-07-26 20:47 ` [ 45/79] fuse: readdirplus: fix dentry leak Greg Kroah-Hartman
2013-07-26 20:47 ` [ 46/79] fuse: readdirplus: fix instantiate Greg Kroah-Hartman
2013-07-26 20:47 ` [ 47/79] fuse: readdirplus: sanity checks Greg Kroah-Hartman
2013-07-26 20:47 ` [ 48/79] bcache: Fix a dumb race Greg Kroah-Hartman
2013-07-26 20:47 ` [ 49/79] bcache: Advertise that flushes are supported Greg Kroah-Hartman
2013-07-26 20:47 ` [ 50/79] bcache: Shutdown fix Greg Kroah-Hartman
2013-07-26 20:47 ` [ 51/79] bcache: Fix a sysfs splat on shutdown Greg Kroah-Hartman
2013-07-26 20:47 ` [ 52/79] bcache: Fix GC_SECTORS_USED() calculation Greg Kroah-Hartman
2013-07-26 20:47 ` [ 53/79] bcache: Journal replay fix Greg Kroah-Hartman
2013-07-26 20:47 ` [ 54/79] EDAC: Fix lockdep splat Greg Kroah-Hartman
2013-07-26 20:47 ` [ 55/79] SCSI: mpt3sas: Infinite loops can occur if MPI2_IOCSTATUS_CONFIG_INVALID_PAGE is not returned Greg Kroah-Hartman
2013-07-26 20:47 ` [ 56/79] SCSI: mpt3sas: fix for kernel panic when driver loads with HBA conected to non LUN 0 configured expander Greg Kroah-Hartman
2013-07-26 20:47 ` [ 57/79] SCSI: megaraid_sas: fix memory leak if SGL has zero length entries Greg Kroah-Hartman
2013-07-26 20:47 ` [ 58/79] lib/Kconfig.debug: Restrict FRAME_POINTER for MIPS Greg Kroah-Hartman
2013-07-26 20:47 ` [ 59/79] usb: serial: option: blacklist ONDA MT689DC QMI interface Greg Kroah-Hartman
2013-07-26 20:47 ` [ 60/79] usb: option: add TP-LINK MA260 Greg Kroah-Hartman
2013-07-26 20:47 ` [ 61/79] usb: serial: option: add Olivetti Olicard 200 Greg Kroah-Hartman
2013-07-26 20:47 ` [ 62/79] usb: serial: option.c: remove ONDA MT825UP product ID fromdriver Greg Kroah-Hartman
2013-07-26 20:47 ` [ 63/79] USB: option: append Petatel NP10T device to GSM modems list Greg Kroah-Hartman
2013-07-26 20:47 ` [ 64/79] USB: option: add D-Link DWM-152/C1 and DWM-156/C1 Greg Kroah-Hartman
2013-07-26 20:47 ` [ 65/79] usb: serial: option: Add ONYX 3G device support Greg Kroah-Hartman
2013-07-26 20:47 ` [ 66/79] ARM: S3C24XX: Add missing clkdev entries for s3c2440 UART Greg Kroah-Hartman
2013-07-26 20:47 ` [ 67/79] ARM: footbridge: fix overlapping PCI mappings Greg Kroah-Hartman
2013-07-26 20:47 ` [ 68/79] usb: serial: cp210x: Add USB ID for Netgear Switches embedded serial adapter Greg Kroah-Hartman
2013-07-26 20:47 ` [ 69/79] USB: cp210x: add MMB and PI ZigBee USB Device Support Greg Kroah-Hartman
2013-07-26 20:48 ` [ 70/79] usb: cp210x support SEL C662 Vendor/Device Greg Kroah-Hartman
2013-07-26 20:48 ` [ 71/79] ext4: fix error handling in ext4_ext_truncate() Greg Kroah-Hartman
2013-07-27 21:33   ` Ben Hutchings
2013-07-28 11:40     ` Theodore Ts'o
2013-07-28 18:27       ` Greg Kroah-Hartman
2013-07-28 21:15       ` Ben Hutchings
2013-07-26 20:48 ` [ 72/79] PM / Sleep: avoid autosleep in shutdown progress Greg Kroah-Hartman
2013-07-26 20:48 ` [ 73/79] media: saa7134: Fix unlocked snd_pcm_stop() call Greg Kroah-Hartman
2013-07-26 20:48 ` [ 74/79] media: dmxdev: remove dvb_ringbuffer_flush() on writer side Greg Kroah-Hartman
2013-07-26 20:48 ` [ 75/79] lockd: protect nlm_blocked access in nlmsvc_retry_blocked Greg Kroah-Hartman
2013-07-26 20:48 ` [ 76/79] hrtimers: Move SMP function call to thread context Greg Kroah-Hartman
2013-07-26 20:48 ` [ 77/79] ALSA: hda - Remove NO_PRESENCE bit override for Dell 1420n Laptop Greg Kroah-Hartman
2013-07-26 20:48 ` [ 78/79] ALSA: usb-audio: 6fire: return correct XRUN indication Greg Kroah-Hartman
2013-07-26 20:48 ` [ 79/79] ALSA: hda - Fix EAPD GPIO control for Sigmatel codecs Greg Kroah-Hartman
2013-07-27  0:19 ` [ 00/79] 3.10.4-stable review Shuah Khan
2013-07-27  0:57   ` Greg Kroah-Hartman
2013-07-28  0:48 ` linux
2013-07-28 18:26   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130726204722.376058298@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=joe.jin@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox