* [PATCH] can-raw: Fix skb_orphan_try handling
@ 2010-07-30 9:44 Oliver Hartkopp
2010-08-01 8:03 ` David Miller
0 siblings, 1 reply; 10+ messages in thread
From: Oliver Hartkopp @ 2010-07-30 9:44 UTC (permalink / raw)
To: Eric Dumazet; +Cc: SocketCAN Core Mailing List, Linux Netdev List, Patrick Ohly
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 <socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
---
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;
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] can-raw: Fix skb_orphan_try handling
2010-07-30 9:44 [PATCH] can-raw: Fix skb_orphan_try handling Oliver Hartkopp
@ 2010-08-01 8:03 ` David Miller
[not found] ` <20100801.010337.68133932.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: David Miller @ 2010-08-01 8:03 UTC (permalink / raw)
To: socketcan
Cc: eric.dumazet, patrick.ohly, netdev, socketcan-core,
matthias.fuchs
From: Oliver Hartkopp <socketcan@hartkopp.net>
Date: Fri, 30 Jul 2010 11:44:27 +0200
> 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
Your patch sets this new value, but I never see it getting tested anywhere.
How does this work?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] can-raw: Fix skb_orphan_try handling
[not found] ` <20100801.010337.68133932.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
@ 2010-08-01 10:50 ` Oliver Hartkopp
2010-08-03 7:30 ` David Miller
0 siblings, 1 reply; 10+ messages in thread
From: Oliver Hartkopp @ 2010-08-01 10:50 UTC (permalink / raw)
To: David Miller
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
netdev-u79uwXL29TY76Z2rM5mHXA,
patrick.ohly-ral2JQCrhuEAvxtiuMwx3w,
eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w
On 01.08.2010 10:03, David Miller wrote:
> From: Oliver Hartkopp <socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
> Date: Fri, 30 Jul 2010 11:44:27 +0200
>
>> 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
>
> Your patch sets this new value, but I never see it getting tested anywhere.
>
> How does this work?
The flags are tested all together in skb_orphan_try() ...
See at
http://git.kernel.org/?p=linux/kernel/git/davem/net-next-2.6.git;a=commitdiff;h=fc6055a5ba31e2c14e36e8939f9bf2b6d586a7f5
+/*
+ * Try to orphan skb early, right before transmission by the device.
+ * We cannot orphan skb if tx timestamp is requested, since
+ * drivers need to call skb_tstamp_tx() to send the timestamp.
+ */
+static inline void skb_orphan_try(struct sk_buff *skb)
+{
+ if (!skb_tx(skb)->flags)
+ skb_orphan(skb);
+}
So my patch just added a new bit that's tested here but does not touch the
rest of the tx timestamp bits that are checked at this place.
Regards,
Oliver
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] can-raw: Fix skb_orphan_try handling
2010-08-01 10:50 ` Oliver Hartkopp
@ 2010-08-03 7:30 ` David Miller
[not found] ` <20100803.003056.216763358.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: David Miller @ 2010-08-03 7:30 UTC (permalink / raw)
To: socketcan
Cc: eric.dumazet, patrick.ohly, netdev, socketcan-core,
matthias.fuchs
From: Oliver Hartkopp <socketcan@hartkopp.net>
Date: Sun, 01 Aug 2010 12:50:16 +0200
> On 01.08.2010 10:03, David Miller wrote:
>> From: Oliver Hartkopp <socketcan@hartkopp.net>
>> Date: Fri, 30 Jul 2010 11:44:27 +0200
>>
>>> 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
>>
>> Your patch sets this new value, but I never see it getting tested anywhere.
>>
>> How does this work?
>
>
> The flags are tested all together in skb_orphan_try() ...
This is why I hate using unions in situations like this... it makes
code impossible to audit easily.
This damn thing should just be a "u8 flags" and a bunch of bit mask
CPP macro defines for the various boolean values.
Anyways, I'll apply your patch thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] can-raw: Fix skb_orphan_try handling
[not found] ` <20100803.003056.216763358.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
@ 2010-08-03 15:22 ` Oliver Hartkopp
2010-08-03 16:14 ` Patrick Ohly
0 siblings, 1 reply; 10+ messages in thread
From: Oliver Hartkopp @ 2010-08-03 15:22 UTC (permalink / raw)
To: David Miller
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
netdev-u79uwXL29TY76Z2rM5mHXA,
patrick.ohly-ral2JQCrhuEAvxtiuMwx3w,
eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w
On 03.08.2010 09:30, David Miller wrote:
> From: Oliver Hartkopp <socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
> Date: Sun, 01 Aug 2010 12:50:16 +0200
>
>> On 01.08.2010 10:03, David Miller wrote:
>>> From: Oliver Hartkopp <socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
>>> Date: Fri, 30 Jul 2010 11:44:27 +0200
>>>
>>>> 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
>>>
>>> Your patch sets this new value, but I never see it getting tested anywhere.
>>>
>>> How does this work?
>>
>>
>> The flags are tested all together in skb_orphan_try() ...
>
> This is why I hate using unions in situations like this... it makes
> code impossible to audit easily.
>
> This damn thing should just be a "u8 flags" and a bunch of bit mask
> CPP macro defines for the various boolean values.
Yep! I also felt like this.
Maybe Patrick Ohly can give some feedback, if he's ok with that kind of
change. So far there are only a few places that would need to be changed for
the flags bitops.
> Anyways, I'll apply your patch thanks.
Thanks!
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] can-raw: Fix skb_orphan_try handling
2010-08-03 15:22 ` Oliver Hartkopp
@ 2010-08-03 16:14 ` Patrick Ohly
[not found] ` <1280852081.3266.834.camel-/oqbx4SGF9pV+x+AlpbFz62pdiUAq4bhAL8bYrjMMd8@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: Patrick Ohly @ 2010-08-03 16:14 UTC (permalink / raw)
To: Oliver Hartkopp
Cc: David Miller, eric.dumazet@gmail.com, netdev@vger.kernel.org,
socketcan-core@lists.berlios.de, matthias.fuchs@esd.eu
On Tue, 2010-08-03 at 18:22 +0300, Oliver Hartkopp wrote:
> >> The flags are tested all together in skb_orphan_try() ...
> >
> > This is why I hate using unions in situations like this... it makes
> > code impossible to audit easily.
> >
> > This damn thing should just be a "u8 flags" and a bunch of bit mask
> > CPP macro defines for the various boolean values.
>
> Yep! I also felt like this.
>
> Maybe Patrick Ohly can give some feedback, if he's ok with that kind of
> change. So far there are only a few places that would need to be changed for
> the flags bitops.
I'm fine with using a simple u8. I'm not sure where I picked up the
union thing, it's not something that I usually do in my own code.
--
Best Regards, Patrick Ohly
The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] can-raw: Fix skb_orphan_try handling
[not found] ` <1280852081.3266.834.camel-/oqbx4SGF9pV+x+AlpbFz62pdiUAq4bhAL8bYrjMMd8@public.gmane.org>
@ 2010-08-03 17:11 ` Oliver Hartkopp
2010-08-03 17:33 ` Patrick Ohly
0 siblings, 1 reply; 10+ messages in thread
From: Oliver Hartkopp @ 2010-08-03 17:11 UTC (permalink / raw)
To: Patrick Ohly
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, David Miller,
eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
On 03.08.2010 18:14, Patrick Ohly wrote:
> On Tue, 2010-08-03 at 18:22 +0300, Oliver Hartkopp wrote:
>>>> The flags are tested all together in skb_orphan_try() ...
>>>
>>> This is why I hate using unions in situations like this... it makes
>>> code impossible to audit easily.
>>>
>>> This damn thing should just be a "u8 flags" and a bunch of bit mask
>>> CPP macro defines for the various boolean values.
>>
>> Yep! I also felt like this.
>>
>> Maybe Patrick Ohly can give some feedback, if he's ok with that kind of
>> change. So far there are only a few places that would need to be changed for
>> the flags bitops.
>
> I'm fine with using a simple u8. I'm not sure where I picked up the
> union thing, it's not something that I usually do in my own code.
>
:-)
Im currently busy until next week, would you like to provide a patch?
Regards,
Oliver
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] can-raw: Fix skb_orphan_try handling
2010-08-03 17:11 ` Oliver Hartkopp
@ 2010-08-03 17:33 ` Patrick Ohly
[not found] ` <1280856828.3266.839.camel-/oqbx4SGF9pV+x+AlpbFz62pdiUAq4bhAL8bYrjMMd8@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: Patrick Ohly @ 2010-08-03 17:33 UTC (permalink / raw)
To: Oliver Hartkopp
Cc: David Miller, eric.dumazet@gmail.com, netdev@vger.kernel.org,
socketcan-core@lists.berlios.de, matthias.fuchs@esd.eu
On Tue, 2010-08-03 at 10:11 -0700, Oliver Hartkopp wrote:
> > I'm fine with using a simple u8. I'm not sure where I picked up the
> > union thing, it's not something that I usually do in my own code.
> >
>
> :-)
>
> Im currently busy until next week, would you like to provide a patch?
Sorry, I have to pass. I'm busy elsewhere myself. MeeGo and
SyncEvolution plus real life consume all of my time nowadays.
--
Best Regards, Patrick Ohly
The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] can-raw: Fix skb_orphan_try handling
[not found] ` <1280856828.3266.839.camel-/oqbx4SGF9pV+x+AlpbFz62pdiUAq4bhAL8bYrjMMd8@public.gmane.org>
@ 2010-08-03 17:50 ` Oliver Hartkopp
2010-08-03 23:28 ` David Miller
0 siblings, 1 reply; 10+ messages in thread
From: Oliver Hartkopp @ 2010-08-03 17:50 UTC (permalink / raw)
To: Patrick Ohly
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, David Miller,
eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
On 03.08.2010 19:33, Patrick Ohly wrote:
> On Tue, 2010-08-03 at 10:11 -0700, Oliver Hartkopp wrote:
>>> I'm fine with using a simple u8. I'm not sure where I picked up the
>>> union thing, it's not something that I usually do in my own code.
>>>
>>
>> :-)
>>
>> Im currently busy until next week, would you like to provide a patch?
>
> Sorry, I have to pass. I'm busy elsewhere myself. MeeGo and
> SyncEvolution plus real life consume all of my time nowadays.
Working for MeeGo is a good excuse ;-)
Will pick that task next week.
BR,
Oliver
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] can-raw: Fix skb_orphan_try handling
2010-08-03 17:50 ` Oliver Hartkopp
@ 2010-08-03 23:28 ` David Miller
0 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2010-08-03 23:28 UTC (permalink / raw)
To: socketcan
Cc: patrick.ohly, eric.dumazet, netdev, socketcan-core,
matthias.fuchs
From: Oliver Hartkopp <socketcan@hartkopp.net>
Date: Tue, 03 Aug 2010 19:50:27 +0200
> On 03.08.2010 19:33, Patrick Ohly wrote:
>> On Tue, 2010-08-03 at 10:11 -0700, Oliver Hartkopp wrote:
>>>> I'm fine with using a simple u8. I'm not sure where I picked up the
>>>> union thing, it's not something that I usually do in my own code.
>>>>
>>>
>>> :-)
>>>
>>> Im currently busy until next week, would you like to provide a patch?
>>
>> Sorry, I have to pass. I'm busy elsewhere myself. MeeGo and
>> SyncEvolution plus real life consume all of my time nowadays.
>
> Working for MeeGo is a good excuse ;-)
>
> Will pick that task next week.
Thanks guys.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-08-03 23:27 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-30 9:44 [PATCH] can-raw: Fix skb_orphan_try handling Oliver Hartkopp
2010-08-01 8:03 ` David Miller
[not found] ` <20100801.010337.68133932.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2010-08-01 10:50 ` Oliver Hartkopp
2010-08-03 7:30 ` David Miller
[not found] ` <20100803.003056.216763358.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2010-08-03 15:22 ` Oliver Hartkopp
2010-08-03 16:14 ` Patrick Ohly
[not found] ` <1280852081.3266.834.camel-/oqbx4SGF9pV+x+AlpbFz62pdiUAq4bhAL8bYrjMMd8@public.gmane.org>
2010-08-03 17:11 ` Oliver Hartkopp
2010-08-03 17:33 ` Patrick Ohly
[not found] ` <1280856828.3266.839.camel-/oqbx4SGF9pV+x+AlpbFz62pdiUAq4bhAL8bYrjMMd8@public.gmane.org>
2010-08-03 17:50 ` Oliver Hartkopp
2010-08-03 23:28 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).