Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp249072pxa; Tue, 4 Aug 2020 04:49:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzN1+g1NpJhKd2k/2AQq1Ddcd0DKHTZTZrAljFhB9pLnrfUDbcY1TpnVCh13LKlj0YO3hYF X-Received: by 2002:a17:906:7492:: with SMTP id e18mr20694203ejl.375.1596541749584; Tue, 04 Aug 2020 04:49:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596541749; cv=none; d=google.com; s=arc-20160816; b=PD1I4A5bvduyE974ZUtvkaQpl+Rlm3BOddvxxrvAAcJboLdKwLc4o7Ia2mx2gqPG/d RYTd2la4DwNMLkk3E2xuIpgcguRvf+zjv8vOkofh/ZlU4wp3J5d9vaWbzecobmRN768E av81b0CIbs522uQD8lG9DOEjwlYS0MenKTbBkwK1scpPFQLu11FxEgKtMrWNseH1cmks 8CtTdqmjTM+GTHzUpKpFvk4V7bWqg57IV0EfzLjXHjDFujd2d2s0kvpqY4urcXFVGvui N279AgKKDWvnecFthIiEUHaDRdp6xb9SXUmkgDjvrRv9HiRyJpqh5s1WsPiqbbvmA/5s rJ+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=9Hkk5eZ/ADrnm42/8pUC+WqeIx8B9ormNQEfuRm2Aj8=; b=bBWQrLmi9kGV3eCmjxbZdNn8LUWz/oLXjVF9vTF9nm6KkefaALqzuqYuVyafOqRB7k b+/9iR0jyZyUU7e2Q4Q6bs2THW5B3mHO12vc+ing6Rkdru2pL5sv6f/w7I2XfT9lTmqd Px1BJwKD4/6GjBByuvF1dvkSSDPcvNfzD8XEZMnZsrITePoovLu4it/z/hj5DYPwX2YK BC2288DEQbLKkcMOcj6G9iw5FTie7NLgsMpj12gQlYpkW2V0L/VUEzJPx+T4e0vkR2d2 40QoJJGbuDk29BgIHPJN1dTkYYGucya71/AgMUCqsaYpVMCWelOVq3cLVPPvBVWAg0j6 /UZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p12si4392201edi.348.2020.08.04.04.48.47; Tue, 04 Aug 2020 04:49:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730251AbgHDLqA (ORCPT + 99 others); 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 Content-Type: text/plain X-Originating-IP: [10.175.101.6] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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)) -- 2.19.1