From patchwork Tue Aug 4 11:48:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 262733 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83E46C433E1 for ; Tue, 4 Aug 2020 11:46:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 72E9B20738 for ; Tue, 4 Aug 2020 11:46:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730263AbgHDLqA (ORCPT ); Tue, 4 Aug 2020 07:46:00 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8758 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728157AbgHDLp7 (ORCPT ); Tue, 4 Aug 2020 07:45:59 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id F22B52BADDED43D36394; Tue, 4 Aug 2020 19:45:55 +0800 (CST) Received: from huawei.com (10.175.101.6) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Tue, 4 Aug 2020 19:45:46 +0800 From: linmiaohe To: , , , , , , , , , , , CC: , , Subject: [PATCH] net: Fix potential out of bound write in skb_try_coalesce() Date: Tue, 4 Aug 2020 19:48:18 +0800 Message-ID: <1596541698-18938-1-git-send-email-linmiaohe@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.175.101.6] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Miaohe Lin 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 --- 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))