From patchwork Fri Jul 30 09:44:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Hartkopp X-Patchwork-Id: 60343 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 BDAE2B70CB for ; Fri, 30 Jul 2010 19:44:38 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756096Ab0G3Joc (ORCPT ); Fri, 30 Jul 2010 05:44:32 -0400 Received: from mo-p00-ob.rzone.de ([81.169.146.161]:58463 "EHLO mo-p00-ob.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755753Ab0G3Job (ORCPT ); Fri, 30 Jul 2010 05:44:31 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1280483069; l=1978; s=domk; d=hartkopp.net; h=Content-Transfer-Encoding:Content-Type:Subject:CC:To:MIME-Version: From:Date:X-RZG-CLASS-ID:X-RZG-AUTH; bh=R0poVPksK4bLQA/XvGHG+VVE8OQ=; b=FIdJqOVmw5fG0GVfP0lphj61jGdO/VzegPJDcuD+v208Viwx1mMPJIB+K428+k1lVgG YWi3BZzEbm+5DSxtcGRnqMHGUg1QvyBBHkj+m3HSUpIz8b/lDJHiEgfzTaCyJN58CyLw/ UbUMWs2oA2+mk+JfU6yx31+yPDJcdgnjvnc= X-RZG-AUTH: :P2MHfkW8eP4Mre39l357AZT/I7AY/7nT2yrAyK0j4gdocU+J8sQnrTpdSDJj2Dvf X-RZG-CLASS-ID: mo00 Received: from [109.40.168.92] (ip-109-40-168-92.web.vodafone.de [109.40.168.92]) by post.strato.de (klopstock mo7) (RZmta 23.4) with ESMTP id 606d86m6U8NRXh ; Fri, 30 Jul 2010 11:44:26 +0200 (MEST) Message-ID: <4C529EFB.4090601@hartkopp.net> Date: Fri, 30 Jul 2010 11:44:27 +0200 From: Oliver Hartkopp User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100619 Icedove/3.0.5 MIME-Version: 1.0 To: Eric Dumazet CC: Patrick Ohly , Linux Netdev List , SocketCAN Core Mailing List , Matthias Fuchs Subject: [PATCH] can-raw: Fix skb_orphan_try handling Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hello Eric, hello Patrick, Commit fc6055a5ba31e2c14e36e8939f9bf2b6d586a7f5 (net: Introduce skb_orphan_try()) allows an early orphan of the skb and takes care on tx timestamping, which needs the sk-reference in the skb on driver level. So does the can-raw socket, which has not been taken into account here. The patch below adds a 'prevent_sk_orphan' bit in the skb tx shared info, which fixes the problem discovered by Matthias Fuchs here: http://marc.info/?t=128030411900003&r=1&w=2 Even if it's not a primary tx timestamp topic it fits well into some skb shared tx context. Or should be find a different place for the information to protect the sk reference until it reaches the driver level? Regards, Oliver This patch applies on net-2.6 and would be a candidate for stable 2.6.34 also. Signed-off-by: Oliver Hartkopp --- -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index f89e7fd..eb674b7 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -169,6 +169,7 @@ struct skb_shared_hwtstamps { * @software: generate software time stamp * @in_progress: device driver is going to provide * hardware time stamp + * @prevent_sk_orphan: make sk reference available on driver level * @flags: all shared_tx flags * * These flags are attached to packets as part of the @@ -178,7 +179,8 @@ union skb_shared_tx { struct { __u8 hardware:1, software:1, - in_progress:1; + in_progress:1, + prevent_sk_orphan:1; }; __u8 flags; }; diff --git a/net/can/raw.c b/net/can/raw.c index da99cf1..eedab37 100644 --- a/net/can/raw.c +++ b/net/can/raw.c @@ -655,6 +655,10 @@ static int raw_sendmsg(struct kiocb *iocb, struct socket *sock, err = sock_tx_timestamp(msg, sk, skb_tx(skb)); if (err < 0) goto free_skb; + + /* to be able to check the received tx sock reference in raw_rcv() */ + (skb_tx(skb))->prevent_sk_orphan = 1; + skb->dev = dev; skb->sk = sk;