Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp5420933rwj; Wed, 21 Dec 2022 02:22:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXsSDy+gdvtkmUIaa+LG3zl2u+I3AB5GpJu+OOY1/zPBFUmQFt566Ho0tLAX/Qt4A49okzAa X-Received: by 2002:a17:90a:384e:b0:223:e475:bd40 with SMTP id l14-20020a17090a384e00b00223e475bd40mr1539538pjf.13.1671618146902; Wed, 21 Dec 2022 02:22:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671618146; cv=none; d=google.com; s=arc-20160816; b=PM6WWx+rhc21IQ1uzbd/6W5yfxpLdPaB+FCKciLRunTlOUvfqJjo3lN1Bn/QTePQvF 80RJ/QN8Iiud7o7lbngLpv8GYI15kc+sFrahv1vFrotkRdmgQEHdn7PCz6tyZTPQ1csl S11xakDybFLbwkK7NCWRa6KY2Vpil0KMxwCuRH++1gEov40RHTE5Mz2bcZXzt/wv8Sks /+MYdJPMqu+vTKL+BLe4VVFGWaCG4gJGecXeBBJaWTiGkDCRNuvETBhMinldaEjQG66C EKiVd/RCfzxVvbCb/Sorj9++hRUCOaXRulExkT+UsmoJQqDdyug36KnB/ygh2VXl2Qri ukRA== 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=0DqqQu4/p5Bu6Q7O7nz3+VdKcBNnQK+05f7RglHv4Ow=; b=e2TAaqFovcKQibRnu0mVDyJJewUZGsTUF4zmZ99k8i8IAOm1a9P3G9AqctgSayaPE/ B0unXH/NjijGE1alIwf/r6BiY7iXDLwiwHPu+uNUgqhctB6yhQxFo7nZR8k3E/ijPW0U 1/hBQRoEFSVJziKeJinPI7bCH8bsvgiNjP9CAvxmFiV+99/VOMtwakYAbq+TKH/CTvDO gRdax2tUbZgz0Lwgj6SkUKqAi7ye7EQQRnBW1CwPOuDtLmxU1mMSZi0wRwmWw002FEY7 61a6dEaxkyIdd2jilrPAsULWIerZRBWhqoZg2S6iWqfigI3TUcxrdSVZOiO868J31Baj Yu/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M7kxC1+C; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f2-20020a17090aa78200b00219ff54ef23si1300262pjq.107.2022.12.21.02.22.18; Wed, 21 Dec 2022 02:22:26 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=M7kxC1+C; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234737AbiLUJwn (ORCPT + 69 others); Wed, 21 Dec 2022 04:52:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234760AbiLUJwB (ORCPT ); Wed, 21 Dec 2022 04:52:01 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E3A52315D for ; Wed, 21 Dec 2022 01:48:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671616121; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0DqqQu4/p5Bu6Q7O7nz3+VdKcBNnQK+05f7RglHv4Ow=; b=M7kxC1+CrO5KHOlI+en7V2Ny17G+i4uYKcyyVtrdhG1dl8XxcTbhlifOcZflMjUT+UCM7v ERK9oaRTD32CoVfp+pTXA6kEiP7FoGP4x1RL8oJNdapPHvx8VXpsgCz9+yrE84qU84TC4G zWj98I5HihrRAtJ0FZSaOSh1DHhOWik= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-247-kjfbH-8KNd6mFHMZsLusZA-1; Wed, 21 Dec 2022 04:48:39 -0500 X-MC-Unique: kjfbH-8KNd6mFHMZsLusZA-1 Received: by mail-ej1-f70.google.com with SMTP id hq42-20020a1709073f2a00b007c100387d64so10092714ejc.3 for ; Wed, 21 Dec 2022 01:48:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0DqqQu4/p5Bu6Q7O7nz3+VdKcBNnQK+05f7RglHv4Ow=; b=KSurU+FCHJpVrZFfuqq+4wVgxSy/mIFOott6uNvJvL0GxpMhwVvYLuBCAHTf+Enl8w wumvFY9QwJSIPzu6gKh5MK2cdi3nnJwiIT14nk4LMzGEIiam3tLRxkhfBd0GqL5Q4KF2 urGzhHpa7FcD3U0qHJp1BrDYUehsLFOSnXvgSRMOTclP4h4mzGk2Rwm26qXmvMcXrpXG TC8J1NuMojMD1ZCIzZNYwBXBggNhO+nxOKSy3ZV7qiFEJ0hGxwNfsBniS7Pnfz1kBh+P uavST4WLL7JrUci64yxHLSnOOr1VtFhcrdC2mJ9wfUqRV6PFHbQcJu3NYbYxXVDRQdo6 C6mw== X-Gm-Message-State: AFqh2kq/xekrSSotymD1ZTbbeB8S3jP9Mz73Y94xlRMMtHVweke49xM6 T8BI65Y4TrDqQCNwcR3JkixhC3kEJSABkfhyTFXV7bUbE6Tn+P64XSugrOjXyLNyI9TM4b8D4MZ uhzLPRukFT7bf96YqNI4Mg/DQ X-Received: by 2002:a17:907:c315:b0:7c1:b65:11d with SMTP id tl21-20020a170907c31500b007c10b65011dmr753066ejc.12.1671616118848; Wed, 21 Dec 2022 01:48:38 -0800 (PST) X-Received: by 2002:a17:907:c315:b0:7c1:b65:11d with SMTP id tl21-20020a170907c31500b007c10b65011dmr753056ejc.12.1671616118637; Wed, 21 Dec 2022 01:48:38 -0800 (PST) Received: from [10.39.192.150] (5920ab7b.static.cust.trined.nl. [89.32.171.123]) by smtp.gmail.com with ESMTPSA id z1-20020a1709063a0100b00780982d77d1sm6815795eje.154.2022.12.21.01.48.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Dec 2022 01:48:38 -0800 (PST) From: Eelco Chaudron To: Aaron Conole Cc: netdev@vger.kernel.org, Pravin B Shelar , Jakub Kicinski , "David S. Miller" , Paolo Abeni , Eric Dumazet , Thomas Graf , dev@openvswitch.org, Ilya Maximets , wangchuanlei , linux-kernel@vger.kernel.org Subject: Re: [PATCH net] net: openvswitch: release vport resources on failure Date: Wed, 21 Dec 2022 10:48:37 +0100 X-Mailer: MailMate (1.14r5933) Message-ID: In-Reply-To: <20221220212717.526780-1-aconole@redhat.com> References: <20221220212717.526780-1-aconole@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 On 20 Dec 2022, at 22:27, Aaron Conole wrote: > A recent commit introducing upcall packet accounting failed to properly= > release the vport object when the per-cpu stats struct couldn't be > allocated. This can cause dangling pointers to dp objects long after > they've been released. > > Cc: Eelco Chaudron > Cc: wangchuanlei > Fixes: 1933ea365aa7 ("net: openvswitch: Add support to count upcall pac= kets") > Reported-by: syzbot+8f4e2dcfcb3209ac35f9@syzkaller.appspotmail.com > Signed-off-by: Aaron Conole > --- Thanks for finding and fixing this! The changes look good to me. Acked-by: Eelco Chaudron > net/openvswitch/datapath.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c > index 932bcf766d63..6774baf9e212 100644 > --- a/net/openvswitch/datapath.c > +++ b/net/openvswitch/datapath.c > @@ -1854,7 +1854,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, st= ruct genl_info *info) > vport->upcall_stats =3D netdev_alloc_pcpu_stats(struct vport_upcall_s= tats_percpu); > if (!vport->upcall_stats) { > err =3D -ENOMEM; > - goto err_destroy_portids; > + goto err_destroy_vport; > } > > err =3D ovs_dp_cmd_fill_info(dp, reply, info->snd_portid, > @@ -1869,6 +1869,8 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, st= ruct genl_info *info) > ovs_notify(&dp_datapath_genl_family, reply, info); > return 0; > > +err_destroy_vport: > + ovs_dp_detach_port(vport); > err_destroy_portids: > kfree(rcu_dereference_raw(dp->upcall_portids)); > err_unlock_and_destroy_meters: > @@ -2316,7 +2318,7 @@ static int ovs_vport_cmd_new(struct sk_buff *skb,= struct genl_info *info) > vport->upcall_stats =3D netdev_alloc_pcpu_stats(struct vport_upcall_s= tats_percpu); > if (!vport->upcall_stats) { > err =3D -ENOMEM; > - goto exit_unlock_free; > + goto exit_unlock_free_vport; > } > > err =3D ovs_vport_cmd_fill_info(vport, reply, genl_info_net(info), > @@ -2336,6 +2338,8 @@ static int ovs_vport_cmd_new(struct sk_buff *skb,= struct genl_info *info) > ovs_notify(&dp_vport_genl_family, reply, info); > return 0; > > +exit_unlock_free_vport: > + ovs_dp_detach_port(vport); > exit_unlock_free: > ovs_unlock(); > kfree_skb(reply); > -- = > 2.31.1