From: linmiaohe <linmiaohe@huawei.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: David Miller <davem@davemloft.net>,
Paolo Abeni <pabeni@redhat.com>, Florian Westphal <fw@strlen.de>,
Pablo Neira Ayuso <pablo@netfilter.org>,
Eric Dumazet <edumazet@google.com>,
Steffen Klassert <steffen.klassert@secunet.com>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
"rdunlap@infradead.org" <rdunlap@infradead.org>,
"decui@microsoft.com" <decui@microsoft.com>,
Jakub Sitnicki <jakub@cloudflare.com>,
"jeremy@azazel.net" <jeremy@azazel.net>,
"mashirle@us.ibm.com" <mashirle@us.ibm.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/5] net: Fix potential deadloop in skb_copy_ubufs()
Date: Fri, 14 Aug 2020 07:14:39 +0000 [thread overview]
Message-ID: <6e3bace9ebea4f59a567a9ab0ef85d90@huawei.com> (raw)
Willem de Bruijn <willemdebruijn.kernel@gmail.com> wrote:
>On Thu, Aug 6, 2020 at 1:48 PM linmiaohe <linmiaohe@huawei.com> wrote:
>>
>> From: Miaohe Lin <linmiaohe@huawei.com>
>>
>> We could be trapped in deadloop when we try to copy userspace skb
>> frags buffers to kernel with a cloned skb:
>> Reproduce code snippet:
>> skb = alloc_skb(UBUF_DATA_LEN, GFP_ATOMIC);
>> clone = skb_clone(skb, GFP_ATOMIC);
>> skb_zcopy_set_nouarg(clone, NULL);
>> pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
>>
>> Catch this unexpected case and return -EINVAL in skb_orphan_frags()
>> before we call skb_copy_ubufs() to fix it.
>
>Is this a hypothetical codepath?
>
>skb zerocopy carefully tracks clone calls where necessary. See the call to skb_orphan_frags in skb_clone, and the implementation of that callee.
>
>The only caller of skb zerocopy with nouarg is tpacket_fill_skb, as of commit 5cd8d46ea156 ("packet: copy user buffers before orphan or clone").
>
>As the commit subject indicates, this sets skb_zcopy_set_nouarg exactly to be sure that any clone will trigger a copy of "zerocopy"
>user data to private kernel memory.
>
>No clone must happen between alloc_skb and skb_zcopy_set_nouarg, indeed. But AFAIK, none exists.
Since we always call skb_orphan_frags in skb_clone, is it unnecessary to call skb_orphan_frags in pskb_expand_head when skb is cloned ?
Thanks.
next reply other threads:[~2020-08-14 7:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-14 7:14 linmiaohe [this message]
2020-08-14 15:14 ` [PATCH 1/5] net: Fix potential deadloop in skb_copy_ubufs() Eric Dumazet
-- strict thread matches above, loose matches on Subject: below --
2020-08-15 2:18 linmiaohe
2020-08-07 9:48 linmiaohe
2020-08-06 11:50 linmiaohe
2020-08-06 12:25 ` Willem de Bruijn
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=6e3bace9ebea4f59a567a9ab0ef85d90@huawei.com \
--to=linmiaohe@huawei.com \
--cc=Jason@zx2c4.com \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=jakub@cloudflare.com \
--cc=jeremy@azazel.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mashirle@us.ibm.com \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=rdunlap@infradead.org \
--cc=steffen.klassert@secunet.com \
--cc=willemdebruijn.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).