mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: linmiaohe <linmiaohe@huawei.com>
To: <davem@davemloft.net>, <kuba@kernel.org>, <pshelar@ovn.org>,
	<fw@strlen.de>, <martin.varghese@nokia.com>, <willemb@google.com>,
	<edumazet@google.com>, <dcaratti@redhat.com>,
	<steffen.klassert@secunet.com>, <pabeni@redhat.com>,
	<shmulik@metanetworks.com>, <kyk.segfault@gmail.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linmiaohe@huawei.com>
Subject: [PATCH] net: Fix potential out of bound write in skb_try_coalesce()
Date: Tue, 4 Aug 2020 19:48:18 +0800	[thread overview]
Message-ID: <1596541698-18938-1-git-send-email-linmiaohe@huawei.com> (raw)

From: Miaohe Lin <linmiaohe@huawei.com>

The head_frag of skb would occupy one extra skb_frag_t. Take it into
account or out of bound write to skb frags may happen.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 net/core/skbuff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 8a0c39e4ab0a..b489ba201fac 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -5154,7 +5154,7 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
 		unsigned int offset;
 
 		if (to_shinfo->nr_frags +
-		    from_shinfo->nr_frags >= MAX_SKB_FRAGS)
+		    from_shinfo->nr_frags + 1 >= MAX_SKB_FRAGS)
 			return false;
 
 		if (skb_head_is_locked(from))
-- 
2.19.1


             reply	other threads:[~2020-08-04 11:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-04 11:48 linmiaohe [this message]
2020-08-04 14:34 ` Eric Dumazet
2020-08-06 11:56 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=1596541698-18938-1-git-send-email-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=steffen.klassert@secunet.com \
    --cc=willemb@google.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

all inboxes | Powered by JetHome®