aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Hartkopp <socketcan@hartkopp.net>2010-08-03 03:31:48 -0400
committerDavid S. Miller <davem@davemloft.net>2010-08-03 03:31:48 -0400
commitcff0d6e6edac7672b3f915bb4fb59f279243b7f9 (patch)
treea12b08344380a9f02c9d043b176b82e921266d6e
parent3578b0c8abc7bdb4f02152ce5db7e09d484c6866 (diff)
can-raw: Fix skb_orphan_try handling
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>
-rw-r--r--include/linux/skbuff.h4
-rw-r--r--net/can/raw.c4
2 files changed, 7 insertions, 1 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index d89876b806a0..d20d9e7a9bbd 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -169,6 +169,7 @@ struct skb_shared_hwtstamps {
169 * @software: generate software time stamp 169 * @software: generate software time stamp
170 * @in_progress: device driver is going to provide 170 * @in_progress: device driver is going to provide
171 * hardware time stamp 171 * hardware time stamp
172 * @prevent_sk_orphan: make sk reference available on driver level
172 * @flags: all shared_tx flags 173 * @flags: all shared_tx flags
173 * 174 *
174 * These flags are attached to packets as part of the 175 * These flags are attached to packets as part of the
@@ -178,7 +179,8 @@ union skb_shared_tx {
178 struct { 179 struct {
179 __u8 hardware:1, 180 __u8 hardware:1,
180 software:1, 181 software:1,
181 in_progress:1; 182 in_progress:1,
183 prevent_sk_orphan:1;
182 }; 184 };
183 __u8 flags; 185 __u8 flags;
184}; 186};
diff --git a/net/can/raw.c b/net/can/raw.c
index ccfe633eec8e..a10e3338f084 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -650,6 +650,10 @@ static int raw_sendmsg(struct kiocb *iocb, struct socket *sock,
650 err = sock_tx_timestamp(msg, sk, skb_tx(skb)); 650 err = sock_tx_timestamp(msg, sk, skb_tx(skb));
651 if (err < 0) 651 if (err < 0)
652 goto free_skb; 652 goto free_skb;
653
654 /* to be able to check the received tx sock reference in raw_rcv() */
655 skb_tx(skb)->prevent_sk_orphan = 1;
656
653 skb->dev = dev; 657 skb->dev = dev;
654 skb->sk = sk; 658 skb->sk = sk;
655 659