Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp370932pxa; Tue, 4 Aug 2020 07:36:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBcYdrezyxoV0HEEs96Qvbhnnlhd0+aPvQuk1jgQPQBfMPGUOqBiTmcY+RJYbxa5PSnvp2 X-Received: by 2002:a17:906:fcdb:: with SMTP id qx27mr1236562ejb.421.1596551807420; Tue, 04 Aug 2020 07:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596551807; cv=none; d=google.com; s=arc-20160816; b=pF15iH0FLlhUvV8537dKdTGqipEP04Jq4gNmz4a3xG0ge4g17SdwPq/rk0LotYaRf+ D30Usn8HhSzzXtO8uqYCg2uBBQK7/V9CkRztnU+O6thaoHzp0v54uukCaZ9d2+0fCiO/ M3C1oQjFIv1lGg4fbRHehCccsl4ncEWzoGcG2LJHPp/2wimGUjhI6fXQRvVwoG6Sma+q 7bjQGI7O2GfbAzA4CwanbDoYyyfvpYptj1XRbGsgZ9L2g//Eaxgq5c3QK2a1ZjOu0Ty5 PKW0euzeBJjoyyfIkxvJj6z5T7XrTw9PiInRNfjedb0VEpn+FIk1bYQ32ALzy0t2Vo9q 2bWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=5Mz7Dz4HhN27ky7XInjg78tahh1Tb1kaHJSAvyuhPZI=; b=vmmdlaLHhyhNflyY+GiXXncWszw3+B3zIe3QByblMdivReBYkzC7Rjh/mHgcdxzOWI kSLvu8hLtENwjEjgrq0n6SyHsLrL37gp6JdcDBWcfRZJfgmrwcokat8SrbpTXzVsOKtB nqfeHQQ7VC//F3LGuHBoSEweM++zSepYvVFIe2MYW3+znCVm0lNyGCYnYbMShua4QTlN gm13PP5npfLP6pvo9frJHAhHdQnPk3PFYvasZq0LN+lytoX06sZ/IhskRP/o/jPrWK3p 6GHVaRJvrpXGtUqNgaxGhYbZlvKzH/DxJjcmWJujAD4s3GPplAH+kMozUu4qdFyL8G+V OgeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=i4UavkhN; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hb17si12315458ejb.576.2020.08.04.07.36.23; Tue, 04 Aug 2020 07:36:47 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=i4UavkhN; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728903AbgHDOfw (ORCPT + 99 others); Tue, 4 Aug 2020 10:35:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726130AbgHDOe2 (ORCPT ); Tue, 4 Aug 2020 10:34:28 -0400 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 972C9C06174A for ; Tue, 4 Aug 2020 07:34:20 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id y18so25923647ilp.10 for ; Tue, 04 Aug 2020 07:34:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5Mz7Dz4HhN27ky7XInjg78tahh1Tb1kaHJSAvyuhPZI=; b=i4UavkhNSo6QPSaRE6hxSLJ+6F/G4lelA0CiGp6bzKeEamYkxGdo6G8aSdhcGOknSp uSeehMryIFLQ5/PIVFsLEqG0whteXirWnqr+iobjI5jXiKjc9NrLfvjtIzN91su38GN7 olOEZsjcLwR/KmjJpRx50bJd22OXG7STLBGX7xSwF1qV+fhvBDs/YKKRfbimFfuryCjo g8v3A7eCk+EzfiiAccNp67TYeYs5OQ16gEXyTYt60Fojyz7b6VZjBBziTGGrQU8lNS1g /UBJjy+AeEPaxczip54KE84qJz1JHuHP/3ck1Z/mUxsMLp1tiWkDsUxAG/hWi0usSIW6 B56A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5Mz7Dz4HhN27ky7XInjg78tahh1Tb1kaHJSAvyuhPZI=; b=ZWFSmRAsIdrmvHYO4YjWR4/BMd1zgFhhMum45clRbO+tGQPfcUmPmmpOYBypJvJlcX 9z/N0uyC1KQqjZa0TxL5y3WrgFlilXyxnzIFQ8kHM1sf9DN+qbgu9QYn1phkX3JWlYEd L5eXjme7iiYXTcnsbzC3uTIdmxLRq1KJE9cVryABmhlnHOFnlylZv1Hjgazs7QpaSToZ i5GDVL3pv/cnVwRvNZXKgf+swKwfGUMaKi7xq+tmWOIGDGoO/+ZB+Qx/5XbNczXFMSB6 5i9jijFqH8HkICP4b/cOL/0yy7r/R1LwGrI27TQ2rbt8A5rKug1xRU3zhPB0268r7S0e dP1A== X-Gm-Message-State: AOAM531mjdUp6ApWzJjfx/W3TV3DFDjxG3hyyWVz+ZCJui6G1bx1irQZ h1u5g9G0SZxAdmwUsCxjF03W/ymovCyyJBVj6mkuIQ== X-Received: by 2002:a92:d781:: with SMTP id d1mr4625475iln.68.1596551659736; Tue, 04 Aug 2020 07:34:19 -0700 (PDT) MIME-Version: 1.0 References: <1596541698-18938-1-git-send-email-linmiaohe@huawei.com> In-Reply-To: <1596541698-18938-1-git-send-email-linmiaohe@huawei.com> From: Eric Dumazet Date: Tue, 4 Aug 2020 07:34:07 -0700 Message-ID: Subject: Re: [PATCH] net: Fix potential out of bound write in skb_try_coalesce() To: linmiaohe Cc: David Miller , Jakub Kicinski , Pravin B Shelar , Florian Westphal , martin.varghese@nokia.com, Willem de Bruijn , Davide Caratti , Steffen Klassert , Paolo Abeni , shmulik@metanetworks.com, kyk.segfault@gmail.com, netdev , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 4, 2020 at 4:46 AM linmiaohe wrote: > > 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 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.