Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp53973rwl; Thu, 3 Nov 2022 19:40:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM450Onzw1kruTBYRiRrBzRefS+m9zIY0IIo0r/MJv5WMpApcXlgUDeW6N7fUyGV343G4Pfu X-Received: by 2002:a17:907:2bf9:b0:7a4:bbce:dd98 with SMTP id gv57-20020a1709072bf900b007a4bbcedd98mr33175288ejc.669.1667529606873; Thu, 03 Nov 2022 19:40:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667529606; cv=none; d=google.com; s=arc-20160816; b=RYkDQ0xV1P10Ar4k/73ZseupOcvpvlYiLTPWx7IOl3s++AEWw92Up1vpFjWI1904an xYNA2hRzcEANcd+pX7Jt0O6pJPTEl0NEcroHicqnJgMjcagcicpGaQ5JCVBdRPQG0cPG P5L66EUuiUDRMjij7oia8GIJczDhInvUwYdcJO609FkdUfXQo/rg+Npfd45/P4P/4RJu HPSMDVDRhz9b9dDD+aZ0EXcwnXHKZH1blP0bIsxw9mzEfbi0/HRhCJDjnn4hh/PzVzT1 Wgm/LlqMHPa/H52NWlooTrHYyJr+vLsScXRZwH8F3B1aip0mEqV8LW59V35xvpcagriu jEZw== 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:subject:cc:to:from:date :dkim-signature; bh=VBE23fbsGqmkl4XGBB9XDLGviYFoYCMpEuD5hznZsTM=; b=Nc4c5bRg9t6FxCG2cj6ALOmPKPJySuHe72lfPZY+keuNTIhKQXBfIpKWjFtlt/Bm4A kGT/XjjDViuT+WGZgq2j9UfCu34ayPrAWsKUFe0zPpuKkadzpeGH6zxIQflS4Ee9Vqhx zMVrwlsTzY+z2ByjJG8ggHk7KFI/QMmmJHXHSO72HMkpkwEvdbtsXkP9OL0JdBo1N1bj WuAG88H4VJLBBTkybaXjzWf+szXQdMzmi8oHhT4HfqMoA4gltqwBg9XcHcOleBTWapQf wDDLLUQ1Sppt6lznCDcGgwK5pRnnnUAtghv8U1/Vq+kddtPIfJS8NtcRvGHWjKAjuZ4t VQQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Muj7FGnR; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t25-20020a056402241900b00461b84a010fsi3387676eda.295.2022.11.03.19.39.43; Thu, 03 Nov 2022 19:40:06 -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=@kernel.org header.s=k20201202 header.b=Muj7FGnR; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230099AbiKDCXQ (ORCPT + 97 others); Thu, 3 Nov 2022 22:23:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbiKDCXN (ORCPT ); Thu, 3 Nov 2022 22:23:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37E48AD; Thu, 3 Nov 2022 19:23:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C3B29B80B03; Fri, 4 Nov 2022 02:23:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC252C433D6; Fri, 4 Nov 2022 02:23:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667528590; bh=sERIijRv5mOrbGOW9mvfJzqTJ1+FOZaz8mhSLFBBd2A=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Muj7FGnRW/uE4Y+G0y4jisxp6d22RyfEzb72tuLQb/iU8GYSSDYv/ibtFqF0gSwlG J7hGBVPU/4/CJohlewT4uWrkFaHXrfFWeNwrUsNrdk27u8s/L2DLdRPHmw99lu4ZI6 gDx1GwK5Kjev0MOrV1kLCiriEEspKiGYxP+57oH2MmlRuIrjLWvlt73RkGYVHgIa8X wMjLxbC/pLONZDNkux4MiQUxmedf/iBYvHLjeuDOtHIHLWUkv9qmDY4PLXlEQcWg5Q V4EsjmNL6zWmG4n5cdddhbck7TqOUoAPSnyHkKb15FWBq/BaGwXLpTvdPhxx6xW9Pw u19p0Sq4y8vuA== Date: Thu, 3 Nov 2022 19:23:08 -0700 From: Jakub Kicinski To: Hawkins Jiawei Cc: 18801353760@163.com, davem@davemloft.net, edumazet@google.com, jhs@mojatatu.com, jiri@resnulli.us, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, syzbot+232ebdbd36706c965ebf@syzkaller.appspotmail.com, syzkaller-bugs@googlegroups.com, xiyou.wangcong@gmail.com Subject: Re: [PATCH] net: sched: fix memory leak in tcindex_set_parms Message-ID: <20221103192308.581a9124@kernel.org> In-Reply-To: <20221103160659.22581-1-yin31149@gmail.com> References: <20221102202604.0d316982@kernel.org> <20221103160659.22581-1-yin31149@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 Fri, 4 Nov 2022 00:07:00 +0800 Hawkins Jiawei wrote: > > Can't you localize all the changes to this if block? > > > > Maybe add a function called tcindex_filter_result_reinit() > > which will act more appropriately? > > I think we shouldn't put the tcf_exts_destroy(&old_e) > into this if block, or other RCU readers may derefer the > freed memory (Please correct me If I am wrong). > > So I put the tcf_exts_destroy(&old_e) near the tcindex > destroy work, after the RCU updateing. I'm not sure what this code is trying to do, to be honest. Your concern that there may be a concurrent reader is valid, but then again tcindex_filter_result_init() just wipes the entire structure with a memset() so concurrent readers are already likely broken? Maybe tcindex_filter_result_init() dates back to times when exts were a list (see commit 22dc13c837c) and calling tcf_exts_init() wasn't that different than cleaning it up? In other words this code is trying to destroy old_r, not reinitialize it? > > > > > err = tcindex_filter_result_init(old_r, cp, net);