diff options
author | Chetan Loke <loke.chetan@gmail.com> | 2011-07-14 11:36:33 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-07-14 11:36:33 -0400 |
commit | cc9f01b246ca8e4fa245991840b8076394f86707 (patch) | |
tree | fb362018297a83c9c288a000893d7dbb88a3aead /net/packet | |
parent | 6a7ebdf2fd15417e87b4fd02ff411aeaca34da5f (diff) |
af-packet: fix - avoid reading stale data
Currently we flush tp_status and then flush the remainder of the header+payload.
tp_status should be flushed in the end to avoid stale data being read by user-space.
Incorrectly re-ordered barriers in v1.
Signed-off-by: Chetan Loke <loke.chetan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/packet')
-rw-r--r-- | net/packet/af_packet.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index d2294ad1a895..c698cec0a445 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -1129,7 +1129,6 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, | |||
1129 | else | 1129 | else |
1130 | sll->sll_ifindex = dev->ifindex; | 1130 | sll->sll_ifindex = dev->ifindex; |
1131 | 1131 | ||
1132 | __packet_set_status(po, h.raw, status); | ||
1133 | smp_mb(); | 1132 | smp_mb(); |
1134 | #if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1 | 1133 | #if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1 |
1135 | { | 1134 | { |
@@ -1138,8 +1137,10 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, | |||
1138 | end = (u8 *)PAGE_ALIGN((unsigned long)h.raw + macoff + snaplen); | 1137 | end = (u8 *)PAGE_ALIGN((unsigned long)h.raw + macoff + snaplen); |
1139 | for (start = h.raw; start < end; start += PAGE_SIZE) | 1138 | for (start = h.raw; start < end; start += PAGE_SIZE) |
1140 | flush_dcache_page(pgv_to_page(start)); | 1139 | flush_dcache_page(pgv_to_page(start)); |
1140 | smp_wmb(); | ||
1141 | } | 1141 | } |
1142 | #endif | 1142 | #endif |
1143 | __packet_set_status(po, h.raw, status); | ||
1143 | 1144 | ||
1144 | sk->sk_data_ready(sk, 0); | 1145 | sk->sk_data_ready(sk, 0); |
1145 | 1146 | ||