From patchwork Wed Jul 13 01:42:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chetan L X-Patchwork-Id: 104462 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 88DA2B6F77 for ; Wed, 13 Jul 2011 11:42:40 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756825Ab1GMBmf (ORCPT ); Tue, 12 Jul 2011 21:42:35 -0400 Received: from mail-vx0-f174.google.com ([209.85.220.174]:33985 "EHLO mail-vx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755008Ab1GMBmf (ORCPT ); Tue, 12 Jul 2011 21:42:35 -0400 Received: by vxb39 with SMTP id 39so3873069vxb.19 for ; Tue, 12 Jul 2011 18:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=nPoPd5LzWCiFhRaQMSx8Sn7w3XdTXEqlzToNP8JJTtc=; b=HoV/T5iQ4Ot/TKKaD5Sf96Ow4gSR+SS9WLCd1sSEMgpUV2jaSR3Wun9xhggPPAIMnQ Ffx1xt4/bobUAwAA18y7zZamUsBJhAkCg5Z7jAF2xeoYXTBe78l1So5iRWwyL5FCeZWT bH1kiDOAErZUd+KMiA5sgxr8/t6zLyRKgywWA= Received: by 10.52.112.104 with SMTP id ip8mr576421vdb.526.1310521354180; Tue, 12 Jul 2011 18:42:34 -0700 (PDT) Received: from localhost (pool-173-48-47-243.bstnma.fios.verizon.net [173.48.47.243]) by mx.google.com with ESMTPS id db1sm1303737vdc.18.2011.07.12.18.42.32 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Jul 2011 18:42:33 -0700 (PDT) From: Chetan Loke To: davem@davemloft.net, netdev@vger.kernel.org Cc: lokechetan@gmail.com, Chetan Loke Subject: [PATCH net-next 1/1] af-packet: fix - avoid reading stale data Date: Tue, 12 Jul 2011 21:42:19 -0400 Message-Id: <1310521339-1115-1-git-send-email-loke.chetan@gmail.com> X-Mailer: git-send-email 1.7.5.2 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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);