]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
can-raw: Fix skb_orphan_try handling
authorOliver Hartkopp <socketcan@hartkopp.net>
Tue, 3 Aug 2010 07:31:48 +0000 (00:31 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 3 Aug 2010 07:31:48 +0000 (00:31 -0700)
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?

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/skbuff.h
net/can/raw.c

index d89876b806a0eb5a79adc0cce7546fca1f95b164..d20d9e7a9bbda130e4499813c10c8c3a82c1bebc 100644 (file)
@@ -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;
 };
index ccfe633eec8e0df4701cd9ff4ad8b57975cb8f88..a10e3338f084aaf15eb73b40d46f1f28e96aaaf7 100644 (file)
@@ -650,6 +650,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;