* [PATCH net-next 1/1] af-packet: fix - avoid reading stale data
@ 2011-07-13 1:42 Chetan Loke
2011-07-13 1:56 ` Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: Chetan Loke @ 2011-07-13 1:42 UTC (permalink / raw)
To: davem, netdev; +Cc: lokechetan, Chetan Loke
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.
Signed-off-by: Chetan Loke <loke.chetan@gmail.com>
---
net/packet/af_packet.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index d2294ad..f7be71f 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1129,8 +1129,6 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
else
sll->sll_ifindex = dev->ifindex;
- __packet_set_status(po, h.raw, status);
- smp_mb();
#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1
{
u8 *start, *end;
@@ -1140,6 +1138,8 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
flush_dcache_page(pgv_to_page(start));
}
#endif
+ smp_mb();
+ __packet_set_status(po, h.raw, status);
sk->sk_data_ready(sk, 0);
--
1.7.5.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next 1/1] af-packet: fix - avoid reading stale data
2011-07-13 1:42 [PATCH net-next 1/1] af-packet: fix - avoid reading stale data Chetan Loke
@ 2011-07-13 1:56 ` Eric Dumazet
2011-07-13 2:19 ` chetan loke
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2011-07-13 1:56 UTC (permalink / raw)
To: Chetan Loke; +Cc: davem, netdev, lokechetan
Le mardi 12 juillet 2011 à 21:42 -0400, Chetan Loke a écrit :
> 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.
>
>
> Signed-off-by: Chetan Loke <loke.chetan@gmail.com>
> ---
> net/packet/af_packet.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
> index d2294ad..f7be71f 100644
> --- a/net/packet/af_packet.c
> +++ b/net/packet/af_packet.c
> @@ -1129,8 +1129,6 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
> else
> sll->sll_ifindex = dev->ifindex;
>
> - __packet_set_status(po, h.raw, status);
> - smp_mb();
> #if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1
> {
> u8 *start, *end;
> @@ -1140,6 +1138,8 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
> flush_dcache_page(pgv_to_page(start));
> }
> #endif
> + smp_mb();
> + __packet_set_status(po, h.raw, status);
>
> sk->sk_data_ready(sk, 0);
>
Are you sure we can perform the flush_dcache_page() before smp_mb() ?
I believe we should do one smp_wmb() before __packet_set_status() as
well.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net-next 1/1] af-packet: fix - avoid reading stale data
2011-07-13 1:56 ` Eric Dumazet
@ 2011-07-13 2:19 ` chetan loke
0 siblings, 0 replies; 3+ messages in thread
From: chetan loke @ 2011-07-13 2:19 UTC (permalink / raw)
To: Eric Dumazet; +Cc: davem, netdev, lokechetan
On Tue, Jul 12, 2011 at 9:56 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> Le mardi 12 juillet 2011 à 21:42 -0400, Chetan Loke a écrit :
>> 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.
>>
>>
>> Signed-off-by: Chetan Loke <loke.chetan@gmail.com>
>> ---
>> net/packet/af_packet.c | 4 ++--
>> 1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
>> index d2294ad..f7be71f 100644
>> --- a/net/packet/af_packet.c
>> +++ b/net/packet/af_packet.c
>> @@ -1129,8 +1129,6 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
>> else
>> sll->sll_ifindex = dev->ifindex;
>>
>> - __packet_set_status(po, h.raw, status);
>> - smp_mb();
>> #if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1
>> {
>> u8 *start, *end;
>> @@ -1140,6 +1138,8 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
>> flush_dcache_page(pgv_to_page(start));
>> }
>> #endif
>> + smp_mb();
>> + __packet_set_status(po, h.raw, status);
>>
>> sk->sk_data_ready(sk, 0);
>>
>
> Are you sure we can perform the flush_dcache_page() before smp_mb() ?
>
> I believe we should do one smp_wmb() before __packet_set_status() as
> well.
Eric - something like this?
#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1
smp_wmb();
#endif
__packet_set_status(po, h.raw, status);
Chetan Loke
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-07-13 2:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-13 1:42 [PATCH net-next 1/1] af-packet: fix - avoid reading stale data Chetan Loke
2011-07-13 1:56 ` Eric Dumazet
2011-07-13 2:19 ` chetan loke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox