From: Daniel Borkmann <daniel@iogearbox•net>
To: Ken-ichirou MATSUZAWA <chamaken@gmail•com>
Cc: David Miller <davem@davemloft•net>, netdev@vger•kernel.org, fw@strlen•de
Subject: Re: [PATCHv1 net-next 0/5] netlink: mmap: kernel panic and some issues
Date: Wed, 02 Sep 2015 11:47:26 +0200 [thread overview]
Message-ID: <55E6C5AE.4060308@iogearbox.net> (raw)
In-Reply-To: <20150902000400.GA14821@gmail.com>
On 09/02/2015 02:04 AM, Ken-ichirou MATSUZAWA wrote:
> On Wed, Aug 19, 2015 at 04:29:32PM +0200, Daniel Borkmann wrote:
>> On 08/17/2015 11:02 PM, David Miller wrote:
>>> From: Daniel Borkmann <daniel@iogearbox•net>
>>> Date: Fri, 14 Aug 2015 12:38:21 +0200
>>>
>>>> diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
>>>> index 67d2104..4307446 100644
>>>> --- a/net/netlink/af_netlink.c
>>>> +++ b/net/netlink/af_netlink.c
>>>> @@ -238,6 +238,13 @@ static void __netlink_deliver_tap(struct sk_buff
>>>> *skb)
>>>>
>>>> static void netlink_deliver_tap(struct sk_buff *skb)
>>>> {
>>>> + /* Netlink mmaped skbs must not access shared info, and thus
>>>> + * are not allowed to be cloned. For now, just don't allow
>>>> + * them to get inspected by taps.
>>>> + */
>>>> + if (netlink_skb_is_mmaped(skb))
>>>> + return;
>>>> +
>>>
>>> I would seriously rather see us do an expensive full copy of the SKB
>>> than to have traffic which is unexpectedly invisible to taps.
>>
>> Do you mean generically as we do in TX path, or only in this
>> particular scenario?
>
> It seems that we only handle this particular scenario.
>
> I think I can understand the cause of the panic. The original mmaped
> skb, allocated by netlink_alloc_skb, has a skb destructor which set
> skb head NULL. This prevents from accessing shared info in
> skb_release_all, so my concerns that the shared info of original skb
> may be accessed in kfree_skb and may cause a panic, is unnecessary.
>
> But since skb_clone does not copy the destructor, skb_release_all
> calls skb_release_data for cloned skb, accessing shared info and
> causes the panic, I think. Setting the destructor after clone could
> not fix the problem since __dev_queue_xmit call path,
> netif_skb_features?, accesses shared info.
>
> Talking about skb_copy path, original skb's shared info is accessed
> only in copy_skb_header, to get gso related field. As a result of
> those, we can avoid the panic by:
>
> @@ -205,7 +205,10 @@ static int __netlink_deliver_tap_skb(struct sk_buff *skb,
> int ret = -ENOMEM;
>
> dev_hold(dev);
> - nskb = skb_clone(skb, GFP_ATOMIC);
> + if (netlink_skb_is_mmaped(skb))
> + nskb = skb_copy(skb, GFP_ATOMIC);
> + else
> + nskb = skb_clone(skb, GFP_ATOMIC);
>
> Thanks to you, my question become clear:
> Should we set gso_size to 0 after copying to make skb_is_gso
> returning false?
It's still not correct. The thing is you can neither call skb_copy() nor
skb_clone() on netlink mmaped skbs. For example, skb_copy_bits() would
look at frags[] in the shared info and tries to copy them. I think adding
extra logic to skb_copy() would be very ugly just to accommodate for this
special case. We need an own netlink_mmap_to_full_skb() handler for this,
that copies/transforms this into a "normal" skb. I'll have a look it this
week.
Thanks,
Daniel
next prev parent reply other threads:[~2015-09-02 9:47 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-22 13:17 [RFC PATCH 0/5] netlink: mmap kernel panic and some issues Ken-ichirou MATSUZAWA
2015-08-12 8:28 ` [PATCHv1 net-next 0/5] netlink: mmap: " Ken-ichirou MATSUZAWA
2015-08-12 8:31 ` [PATCHv1 net-next 1/5] netlink: mmap: introduce mmaped skb helper functions Ken-ichirou MATSUZAWA
2015-08-12 8:32 ` [PATCHv1 net-next 2/5] netlink: mmap: apply " Ken-ichirou MATSUZAWA
2015-08-12 8:34 ` [PATCHv1 net-next 3/5] netlink: mmap: fix status for not delivered skb Ken-ichirou MATSUZAWA
2015-08-12 8:35 ` [PATCHv1 net-next 4/5] netlink: mmap: update tx type check Ken-ichirou MATSUZAWA
2015-08-12 8:38 ` [PATCHv1 net-next 5/5] netlink: mmap: notify only when NL_MMAP_STATUS_VALID frame exists Ken-ichirou MATSUZAWA
2015-08-12 23:38 ` [PATCHv1 net-next 0/5] netlink: mmap: kernel panic and some issues David Miller
2015-08-14 8:58 ` Ken-ichirou MATSUZAWA
2015-08-14 10:01 ` Daniel Borkmann
2015-08-14 10:38 ` Daniel Borkmann
2015-08-15 2:25 ` Ken-ichirou MATSUZAWA
2015-08-17 21:02 ` David Miller
2015-08-19 14:29 ` Daniel Borkmann
2015-09-02 0:04 ` Ken-ichirou MATSUZAWA
2015-09-02 9:47 ` Daniel Borkmann [this message]
2015-09-02 11:35 ` Ken-ichirou MATSUZAWA
2015-09-02 15:56 ` Daniel Borkmann
2015-09-02 22:27 ` Ken-ichirou MATSUZAWA
2015-09-07 14:54 ` Daniel Borkmann
2015-09-09 5:59 ` David Miller
2015-09-09 8:53 ` Thomas Graf
2015-09-09 9:22 ` Daniel Borkmann
2015-08-20 3:43 ` [PATCH net] netlink: mmap: fix tx type check Ken-ichirou MATSUZAWA
2015-08-23 23:06 ` David Miller
2015-08-20 5:54 ` [PATCH net] netlink: rx mmap: fix POLLIN condition Ken-ichirou MATSUZAWA
2015-08-26 3:17 ` David Miller
2015-08-28 7:00 ` Ken-ichirou MATSUZAWA
2015-08-28 7:05 ` [PATCH net] netlink: mmap: fix lookup frame position Ken-ichirou MATSUZAWA
2015-08-29 5:26 ` David Miller
2015-08-30 22:54 ` [PATCH net] netlink: rx mmap: fix POLLIN condition Ken-ichirou MATSUZAWA
2015-08-31 4:56 ` David Miller
2015-08-20 7:07 ` [PATCH net] netlink: mmap: fix status setting in skb destructor Ken-ichirou MATSUZAWA
2015-08-26 3:22 ` David Miller
2015-08-28 7:37 ` Ken-ichirou MATSUZAWA
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55E6C5AE.4060308@iogearbox.net \
--to=daniel@iogearbox$(echo .)net \
--cc=chamaken@gmail$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=fw@strlen$(echo .)de \
--cc=netdev@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox