Message ID | 1596541698-18938-1-git-send-email-linmiaohe@huawei.com |
---|---|
State | Changes Requested |
Delegated to: | David Miller |
Headers | show |
Series | net: Fix potential out of bound write in skb_try_coalesce() | expand |
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.
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))