Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3228204rwd; Mon, 22 May 2023 10:21:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6zuNQ/2pVDcf1ODBpTb8MJOVvbHhOX6gsgfZPzgIsEqxypt1GwwbRs7BUIhyd4BXym01hu X-Received: by 2002:a05:6a21:9999:b0:10a:c09c:bd with SMTP id ve25-20020a056a21999900b0010ac09c00bdmr9448102pzb.55.1684776094154; Mon, 22 May 2023 10:21:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684776094; cv=none; d=google.com; s=arc-20160816; b=FvgQO3uNxsbX+4A7BAkaC4R7J72nf5w/O8OURXXOgIgaAHPJd7we54uLNQieoazg48 HGiBBhOHNZ6Utdo7kpIEflThOfEjCcTQnX/XHabSInkkEvK2P6rrhZEZfJQO8Pa5bBdF SLKtPvfSakXQgtSFKqq5p5U0Ltk6mwn5lWaNljWeL7ODzkBLAbvpoGyt9mtbIuIdKdn/ ZlH19uklzXfkpB3uITWOna+VmyJMBEpBKohtr51kHwQqnUjcLp0vhZbKcDvv3FayLUL6 yyr7FmvVIXIzWhl0vT62bl5bDL7E9TrEQGOVUyATzuO+NQJGxveyRqZIpdnDlNqlHFw6 5EAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=I/SNaVUdIc0hHy+oBRiw3L0eJufVVtqNYeP7Dn1/JwI=; b=Zr0xDRLfoRKAbqY7ltdYWCmp01FFk0vPShuvWJOiEzSkjakxF4V0py7NYKVcinGYS1 AOGNTQa69WFE2bUoEnNbkZPDttLsjn1XUgeRm07YAVCP1m2n89su128wiM4I1MGYWjW3 nBJyfiJL+y98glIz4cnCr4eYuEzi8RT5VJM97bRZGT42k/AjuP07sQZRZMoWsO2OOOAa VDpvIpWOElwxhfw/GT7Amj7DzQbEwH9NKlmyEkijdjXMOSQDOoeCZ8kOqvVdawf0VENF jUtlkZ+IZJPY/+FMMejgyJ7+Use4KoDTa2b1FqK0cok0LpTeQrvVFXjLEA/w6XoGQJFM pZGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=d+P0z6zd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 19-20020a631553000000b005348977b5c5si5025690pgv.97.2023.05.22.10.21.15; Mon, 22 May 2023 10:21:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=d+P0z6zd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230101AbjEVRFi (ORCPT + 99 others); Mon, 22 May 2023 13:05:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231665AbjEVRFg (ORCPT ); Mon, 22 May 2023 13:05:36 -0400 Received: from smtp-fw-2101.amazon.com (smtp-fw-2101.amazon.com [72.21.196.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B7DA100; Mon, 22 May 2023 10:05:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1684775118; x=1716311118; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I/SNaVUdIc0hHy+oBRiw3L0eJufVVtqNYeP7Dn1/JwI=; b=d+P0z6zdAwqH52praqjdhvblzM/mKLup/k5YqYZqXA7WIuqlKADruWWM KG6Ywny66/t9QKmjki6M/bL8F2j0MPaJgwZ0ME8+j8DhSJet3dxbJqwIt uP+srQPibOln6v1Y6qraTWt3h++gIxhD2fPY5sdkfPPi/8hDOSRR9gRT3 M=; X-IronPort-AV: E=Sophos;i="6.00,184,1681171200"; d="scan'208";a="327681135" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2a-m6i4x-21d8d9f4.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2023 17:04:53 +0000 Received: from EX19MTAUWB001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-pdx-2a-m6i4x-21d8d9f4.us-west-2.amazon.com (Postfix) with ESMTPS id 6452180EAB; Mon, 22 May 2023 17:04:48 +0000 (UTC) Received: from EX19D004ANA001.ant.amazon.com (10.37.240.138) by EX19MTAUWB001.ant.amazon.com (10.250.64.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 22 May 2023 17:04:41 +0000 Received: from 88665a182662.ant.amazon.com (10.119.123.82) by EX19D004ANA001.ant.amazon.com (10.37.240.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 22 May 2023 17:04:38 +0000 From: Kuniyuki Iwashima To: CC: , , , , , , , , , Subject: Re: [PATCH net] net: fix skb leak in __skb_tstamp_tx() Date: Mon, 22 May 2023 10:04:30 -0700 Message-ID: <20230522170430.56198-1-kuniyu@amazon.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230522165505.90105-1-sj@kernel.org> References: <20230522165505.90105-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.119.123.82] X-ClientProxiedBy: EX19D033UWC004.ant.amazon.com (10.13.139.225) To EX19D004ANA001.ant.amazon.com (10.37.240.138) X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE,T_SPF_PERMERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: SeongJae Park Date: Mon, 22 May 2023 16:55:05 +0000 > Hi Pratyush, > > On Mon, 22 May 2023 17:30:20 +0200 Pratyush Yadav wrote: > > > Commit 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with > > TX timestamp.") added a call to skb_orphan_frags_rx() to fix leaks with > > zerocopy skbs. But it ended up adding a leak of its own. When > > skb_orphan_frags_rx() fails, the function just returns, leaking the skb > > it just cloned. Free it before returning. > > > > This bug was discovered and resolved using Coverity Static Analysis > > Security Testing (SAST) by Synopsys, Inc. > > > > Fixes: 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with TX timestamp.") > > Seems the commit has merged in several stable kernels. Is the bug also > affecting those? If so, would it be better to Cc stable@vger.kernel.org? In netdev, we add 'net' in Subject for bugfix, then netdev maintainers send a pull request weekly, and stable maintainers backport the fixes to affected trees. So we usually need not CC stable for netdev patches. Thanks, Kuniyuki > > > Thanks, > SJ > > > Signed-off-by: Pratyush Yadav > > --- > > > > I do not know this code very well, this was caught by our static > > analysis tool. I did not try specifically reproducing the leak but I did > > do a boot test by adding this patch on 6.4-rc3 and the kernel boots > > fine. > > > > net/core/skbuff.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/net/core/skbuff.c b/net/core/skbuff.c > > index 515ec5cdc79c..cea28d30abb5 100644 > > --- a/net/core/skbuff.c > > +++ b/net/core/skbuff.c > > @@ -5224,8 +5224,10 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb, > > } else { > > skb = skb_clone(orig_skb, GFP_ATOMIC); > > > > - if (skb_orphan_frags_rx(skb, GFP_ATOMIC)) > > + if (skb_orphan_frags_rx(skb, GFP_ATOMIC)) { > > + kfree_skb(skb); > > return; > > + } > > } > > if (!skb) > > return; > > -- > > 2.39.2 > >