Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp106472rwb; Fri, 4 Aug 2023 09:49:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEjTLwHJjb8nx/QVD/zhG6L1ecphUeUs6av2jC0WU9GR0f9i8mwseJJcc4xlu1UJtTJ4TQG X-Received: by 2002:aa7:cb19:0:b0:522:ca6b:ad7d with SMTP id s25-20020aa7cb19000000b00522ca6bad7dmr1662749edt.9.1691167769195; Fri, 04 Aug 2023 09:49:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691167769; cv=none; d=google.com; s=arc-20160816; b=LvCioqW7SrtR0KMAY5T/dRqRYsJjiDgPMrNi7E104WmaHvr33LLPytVKPZqpgo0wOl JHvA+34ywYX45yVmgMfqJOIGCnqzkf74x+DxmH9FdbFycYC8yBBtQntPo8NXiK05jIGj K4I7iOcVM+YTnpkwc3lCbDr0Xz6F5aSvZzoXezD5/oLe6Vz9be8W5/V61hE6aOonJEge oBlOS0osvV268lW2k9Hu8O5QwpYvaO0N40Chws6InzF87ZA5Ys4PPOJjO0FwLnlMOAlm ZDGwhWMIpdG3RKnNVB9U6VdKHu7jZi5DxcBI7RG/2gJGvZyxfFOi99faK4b/aPQVlBHz 8HqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature; bh=pJgUfuzwp2Plwj/vIlzlhZLLY3But/roBXSqjo4nu/c=; fh=wskIvxBR0MrtrswztyraYpTsyrWapNe0Q6DqlDVZd/o=; b=k2XSfmO6WOXNCwWM5QoKk9MbaxI8zbPzedIZ0nc+OyPZq/r7Sm+U/10jEz1kThDCrJ I+Idnz0xcc126K/ACyFejjl+Nfc3Kx16QucPzOLPF6lSf5wAV3beWL92s99JB5HcEBIt zwDjYbsd4G2TQVQGEGvzmmU2sv6t1fhbcmTpK0lonQKgOZq2lBC0o47rMsAab7hvIEB4 XJd+xCOovz6YZUyYkth55LwRTu041F7FgVzpKidWHFwZnF+VTLwaHJMdE6rTOG9WlR8y TMNF4DY0+Ohf6VdhLemZVD5oI3iZtiDeXdsFhhQQNbs8YaKD5F/BauXnHuvXgqVNW94S 4pHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=1KtCmIz6; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d12-20020a50fb0c000000b0051d8c395a66si1880247edq.53.2023.08.04.09.49.04; Fri, 04 Aug 2023 09:49:29 -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=@messagingengine.com header.s=fm3 header.b=1KtCmIz6; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230191AbjHDNz4 (ORCPT + 99 others); Fri, 4 Aug 2023 09:55:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229782AbjHDNzy (ORCPT ); Fri, 4 Aug 2023 09:55:54 -0400 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC8E51990; Fri, 4 Aug 2023 06:55:50 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 2E9CE5C0140; Fri, 4 Aug 2023 09:24:13 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 04 Aug 2023 09:24:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1691155453; x=1691241853; bh=pJgUfuzwp2Plw j/vIlzlhZLLY3But/roBXSqjo4nu/c=; b=1KtCmIz6+wCPyTbyMCiknH/MxS6Tp 1MqI3ACSZkoIQYejSLXXjmn2piqvZzK67qAi/DM9qLPq/Wr1vZl+Js8aN0082e7+ fhCdqW6wV7cIcGSdWihNAz/ZZvgtvSi5o30G9d47wMjHfqN0KSq0fnb+eG9omvIS 4S9vduEUbnHb0aH+zhJem6arkmNOJbfTqR9en5ce70uHjMhk8VsDhzoFrRY2swUf STNSAluJGUu6eUnS+aTblWE5ESxsXbjUeZkrARVapRBJV3HmTWkqKuHOgWEMXdSV WOJ9oLSKA6QjTnQJWh1hL/ld+OodUx3TUN8op6cjhuc8HuMHaBy/GmBhw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrkeeggdeifecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpefkughoucfu tghhihhmmhgvlhcuoehiughoshgthhesihguohhstghhrdhorhhgqeenucggtffrrghtth gvrhhnpedvteehheeiieekjeffudekhfdthfevudettdelgeehveegteeflefhvdehieeg jeenucffohhmrghinhepkhgvrhhnvghlrdhorhhgpdhlihhnuhigthgvshhtihhnghdroh hrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehi ughoshgthhesihguohhstghhrdhorhhg X-ME-Proxy: Feedback-ID: i494840e7:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Aug 2023 09:24:11 -0400 (EDT) Date: Fri, 4 Aug 2023 16:24:08 +0300 From: Ido Schimmel To: Fedor Pchelkin Cc: Roopa Prabhu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Nikolay Aleksandrov , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org Subject: Re: [PATCH] drivers: vxlan: vnifilter: free percpu vni stats on error path Message-ID: References: <20230803193834.23340-1-pchelkin@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230803193834.23340-1-pchelkin@ispras.ru> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE,URIBL_BLOCKED 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 Prefix should be "PATCH net". See: https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html On Thu, Aug 03, 2023 at 10:38:32PM +0300, Fedor Pchelkin wrote: > In case rhashtable_lookup_insert_fast() fails inside vxlan_vni_add(), the > allocated percpu vni stats are not freed on the error path. > > Free them on the rhashtable_lookup_insert_fast() error path in > vxlan_vni_add(). > > Found by Linux Verification Center (linuxtesting.org). > > Fixes: 4095e0e1328a ("drivers: vxlan: vnifilter: per vni stats") > Signed-off-by: Fedor Pchelkin > --- > drivers/net/vxlan/vxlan_vnifilter.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/vxlan/vxlan_vnifilter.c b/drivers/net/vxlan/vxlan_vnifilter.c > index a3de081cda5e..321cd0b450cc 100644 > --- a/drivers/net/vxlan/vxlan_vnifilter.c > +++ b/drivers/net/vxlan/vxlan_vnifilter.c > @@ -740,6 +740,7 @@ static int vxlan_vni_add(struct vxlan_dev *vxlan, > &vninode->vnode, > vxlan_vni_rht_params); > if (err) { > + free_percpu(vninode->stats); This oversight (and future ones) wouldn't have happened if vxlan_vni_alloc() had a corresponding vxlan_vni_free(). I suggest something like [1]. BTW, I think the GFP_ATOMIC in vxlan_vni_alloc() should be GFP_KERNEL. I will take care of it in net-next. > kfree(vninode); > return err; > } > -- > 2.41.0 [1] diff --git a/drivers/net/vxlan/vxlan_vnifilter.c b/drivers/net/vxlan/vxlan_vnifilter.c index a3de081cda5e..c3ff30ab782e 100644 --- a/drivers/net/vxlan/vxlan_vnifilter.c +++ b/drivers/net/vxlan/vxlan_vnifilter.c @@ -713,6 +713,12 @@ static struct vxlan_vni_node *vxlan_vni_alloc(struct vxlan_dev *vxlan, return vninode; } +static void vxlan_vni_free(struct vxlan_vni_node *vninode) +{ + free_percpu(vninode->stats); + kfree(vninode); +} + static int vxlan_vni_add(struct vxlan_dev *vxlan, struct vxlan_vni_group *vg, u32 vni, union vxlan_addr *group, @@ -740,7 +746,7 @@ static int vxlan_vni_add(struct vxlan_dev *vxlan, &vninode->vnode, vxlan_vni_rht_params); if (err) { - kfree(vninode); + vxlan_vni_free(vninode); return err; } @@ -763,8 +769,7 @@ static void vxlan_vni_node_rcu_free(struct rcu_head *rcu) struct vxlan_vni_node *v; v = container_of(rcu, struct vxlan_vni_node, rcu); - free_percpu(v->stats); - kfree(v); + vxlan_vni_free(v); } static int vxlan_vni_del(struct vxlan_dev *vxlan,