summaryrefslogtreecommitdiff
path: root/net/socket.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2017-02-19 07:17:17 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-02-26 11:10:51 +0100
commit7c56012e92b51030b13c4652a9494d422562d5d5 (patch)
tree10d63b04970e0864293c6a3aebcb56d6be1dc476 /net/socket.c
parentc2219da51664451149350e47321aa0fcf72a8b8f (diff)
ptr_ring: fix race conditions when resizing
[ Upstream commit e71695307114335be1ed912f4a347396c2ed0e69 ] Resizing currently drops consumer lock. This can cause entries to be reordered, which isn't good in itself. More importantly, consumer can detect a false ring empty condition and block forever. Further, nesting of consumer within producer lock is problematic for tun, since it produces entries in a BH, which causes a lock order reversal: CPU0 CPU1 ---- ---- consume: lock(&(&r->consumer_lock)->rlock); resize: local_irq_disable(); lock(&(&r->producer_lock)->rlock); lock(&(&r->consumer_lock)->rlock); <Interrupt> produce: lock(&(&r->producer_lock)->rlock); To fix, nest producer lock within consumer lock during resize, and keep consumer lock during the whole swap operation. Reported-by: Dmitry Vyukov <dvyukov@google.com> Cc: stable@vger.kernel.org Cc: "David S. Miller" <davem@davemloft.net> Acked-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/socket.c')
0 files changed, 0 insertions, 0 deletions