Netdev Archive on lore.kernel.org help / color / mirror / Atom feed
From: Miaohe Lin <linmiaohe@huawei.com> To: <davem@davemloft.net>, <kuba@kernel.org>, <martin.varghese@nokia.com>, <fw@strlen.de>, <pshelar@ovn.org>, <dcaratti@redhat.com>, <edumazet@google.com>, <steffen.klassert@secunet.com>, <pabeni@redhat.com>, <shmulik@metanetworks.com>, <kyk.segfault@gmail.com>, <sowmini.varadhan@oracle.com> Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linmiaohe@huawei.com> Subject: [PATCH] net: handle the return value of pskb_carve_frag_list() correctly Date: Sat, 15 Aug 2020 04:46:41 -0400 [thread overview] Message-ID: <20200815084641.18417-1-linmiaohe@huawei.com> (raw) pskb_carve_frag_list() may return -ENOMEM in pskb_carve_inside_nonlinear(). we should handle this correctly or we would get wrong sk_buff. Fixes: 6fa01ccd8830 ("skbuff: Add pskb_extract() helper function") Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> --- net/core/skbuff.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index bca0d3c7f114..afbc1a79dc8a 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -5987,9 +5987,13 @@ static int pskb_carve_inside_nonlinear(struct sk_buff *skb, const u32 off, if (skb_has_frag_list(skb)) skb_clone_fraglist(skb); - if (k == 0) { - /* split line is in frag list */ - pskb_carve_frag_list(skb, shinfo, off - pos, gfp_mask); + /* split line is in frag list */ + if (k == 0 && pskb_carve_frag_list(skb, shinfo, off - pos, gfp_mask)) { + /* skb_frag_unref() is not needed here as shinfo->nr_frags = 0. */ + if (skb_has_frag_list(skb)) + kfree_skb_list(skb_shinfo(skb)->frag_list); + kfree(data); + return -ENOMEM; } skb_release_data(skb); -- 2.19.1
next reply other threads:[~2020-08-16 0:36 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-08-15 8:46 Miaohe Lin [this message] 2020-08-16 23:01 ` [PATCH] net: handle the return value of pskb_carve_frag_list() correctly David Miller 2020-08-18 22:57 ` David Miller 2020-08-17 2:27 linmiaohe 2020-08-17 4:01 ` David Miller 2020-08-17 11:58 linmiaohe
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=20200815084641.18417-1-linmiaohe@huawei.com \ --to=linmiaohe@huawei.com \ --cc=davem@davemloft.net \ --cc=dcaratti@redhat.com \ --cc=edumazet@google.com \ --cc=fw@strlen.de \ --cc=kuba@kernel.org \ --cc=kyk.segfault@gmail.com \ --cc=linux-kernel@vger.kernel.org \ --cc=martin.varghese@nokia.com \ --cc=netdev@vger.kernel.org \ --cc=pabeni@redhat.com \ --cc=pshelar@ovn.org \ --cc=shmulik@metanetworks.com \ --cc=sowmini.varadhan@oracle.com \ --cc=steffen.klassert@secunet.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: linkBe 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).