All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: Fix potential out of bound write in skb_try_coalesce()
@ 2020-08-04 11:48 linmiaohe
  2020-08-04 14:34 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: linmiaohe @ 2020-08-04 11:48 UTC (permalink / raw)
  To: davem, kuba, pshelar, fw, martin.varghese, willemb, edumazet,
	dcaratti, steffen.klassert, pabeni, shmulik, kyk.segfault
  Cc: netdev, linux-kernel, linmiaohe

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: Fix potential out of bound write in skb_try_coalesce()
  2020-08-04 11:48 [PATCH] net: Fix potential out of bound write in skb_try_coalesce() linmiaohe
@ 2020-08-04 14:34 ` Eric Dumazet
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2020-08-04 14:34 UTC (permalink / raw)
  To: linmiaohe
  Cc: David Miller, Jakub Kicinski, Pravin B Shelar, Florian Westphal,
	martin.varghese, Willem de Bruijn, Davide Caratti,
	Steffen Klassert, Paolo Abeni, shmulik, kyk.segfault, netdev,
	LKML

On Tue, Aug 4, 2020 at 4:46 AM linmiaohe <linmiaohe@huawei.com> wrote:
>
> 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>

Please share a stack trace if this was a real bug spotted in the wild.

I do not believe this patch is correct.

if (A + B >= MAX)   is equivalent to  if (A + B + 1 > MAX)

Note how the other condition (when there is no bytes in skb header) is coded :

if (A + B > MAX) return false;

In anycase, please always provide a Fixes: tag for any bug fix.

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: Fix potential out of bound write in skb_try_coalesce()
@ 2020-08-06 11:56 linmiaohe
  0 siblings, 0 replies; 3+ messages in thread
From: linmiaohe @ 2020-08-06 11:56 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David Miller, Jakub Kicinski, Pravin B Shelar, Florian Westphal,
	martin.varghese, Willem de Bruijn, Davide Caratti,
	Steffen Klassert, Paolo Abeni, shmulik, kyk.segfault, netdev,
	LKML

Eric Dumazet <edumazet@google.com> wrote:
>On Tue, Aug 4, 2020 at 4:46 AM linmiaohe <linmiaohe@huawei.com> wrote:
>>
>> 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.
>>
>
>Please share a stack trace if this was a real bug spotted in the wild.
>
>I do not believe this patch is correct.
>
>if (A + B >= MAX)   is equivalent to  if (A + B + 1 > MAX)
>
>Note how the other condition (when there is no bytes in skb header) is coded :
>
>if (A + B > MAX) return false;
>
>In anycase, please always provide a Fixes: tag for any bug fix.
>
>Thanks.

Many thanks for your patient explaination. I compared (A + B >= MAX) with (A + B + 1 > MAX) in skb_gro_receive(),
but I missed the '='. It's my oversight, I'am really sorry about it.

Thanks again.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-06 20:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04 11:48 [PATCH] net: Fix potential out of bound write in skb_try_coalesce() linmiaohe
2020-08-04 14:34 ` Eric Dumazet
2020-08-06 11:56 linmiaohe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.