]> git.baikalelectronics.ru Git - kernel.git/commit
ptr_ring: add barriers
authorMichael S. Tsirkin <mst@redhat.com>
Tue, 5 Dec 2017 19:29:37 +0000 (21:29 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 11 Dec 2017 15:52:23 +0000 (10:52 -0500)
commited9736f5a800859b28d8715c79fbd64f018644fc
tree768483ddf27f70faa09ffe0f4a0c90a35119f249
parentaba03fb7b9f3fd8ebecf9b0c7a93770a5fb68d05
ptr_ring: add barriers

Users of ptr_ring expect that it's safe to give the
data structure a pointer and have it be available
to consumers, but that actually requires an smb_wmb
or a stronger barrier.

In absence of such barriers and on architectures that reorder writes,
consumer might read an un=initialized value from an skb pointer stored
in the skb array.  This was observed causing crashes.

To fix, add memory barriers.  The barrier we use is a wmb, the
assumption being that producers do not need to read the value so we do
not need to order these reads.

Reported-by: George Cherian <george.cherian@cavium.com>
Suggested-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/ptr_ring.h