Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5663625imm; Mon, 23 Jul 2018 04:00:30 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc7XNiMpuIH9y/ne69EjKqtW2z/LyDI7WMvhennmZGKnhDGu2LvT36pF46FjwPR22BRsSvv X-Received: by 2002:a17:902:b48c:: with SMTP id y12-v6mr12267178plr.97.1532343630609; Mon, 23 Jul 2018 04:00:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532343630; cv=none; d=google.com; s=arc-20160816; b=xo1WNWcZiiKB+rdasMeCahtucy5zxFalokvaJj7tphj7iy3+P/lbZMmXdfw23+lQsi p7eUbkV7/tVKEZ0cgvId8emmOZFIBhOyChc+Mf+OuyqtTtLv8YcfKyKYQlQMUFrQDz4a 1jnTwKiWiVp8ca+MwiyZ/oz8l11up91SKgDXnP7vlQmPqOAcdbwe2MZJLcIXjB2pgfXq Q9CfplJzMBPE3xfquV/qKPhdbPvMhejaUlzpnZ8Xkm50eBPsq5DeDLAIjabxMd1Y4Mkv ROi8dzfUtHAqk+cWeqRV6DrRKzmB5NkZdN/7qEvpcXx/myz8CudQz+SMG/M0P632WqqR humQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=oqtZ1XQLd/q24rBx9dLHt+97zNa4DxKwNVUdx7PsLJg=; b=rU4oflWZVPcUaQB+p4u8H0NNSObMHgSa3C2bzxhiwZYoD9rxmVlrhQzNtKIFeV9yHY rR4842gsyJ64BGR7Ks/ax8K7tfdnJc+dk/UHCJyB2VlK5Jq1Mwgb2rDsZdQ+XE2AX6/b lK4XkEnXsku09MOtgDc+P5cTqrwcVPM9YO5aNoZNNIi+pyIMA75HzNdWWG9jHqdSoX8b wRL13MzQ3VitsmjLniAF5ANFD9ybRNmMobhboSm0LTslLFx9zhIb1J/2E7zwkau4zOZH DE77LMjtrE1kyL7EVe+j6aTzleL/eep3aTB1jLNrQkvYAY5yurdbrSmekdZOagBu71hA RHwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e96-v6si8392131plb.447.2018.07.23.04.00.15; Mon, 23 Jul 2018 04:00:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387957AbeGWMAE (ORCPT + 99 others); Mon, 23 Jul 2018 08:00:04 -0400 Received: from Chamillionaire.breakpoint.cc ([146.0.238.67]:35512 "EHLO Chamillionaire.breakpoint.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387864AbeGWMAD (ORCPT ); Mon, 23 Jul 2018 08:00:03 -0400 Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.89) (envelope-from ) id 1fhYYd-0008LV-UY; Mon, 23 Jul 2018 12:59:16 +0200 Date: Mon, 23 Jul 2018 12:59:15 +0200 From: Florian Westphal To: shaochun chen Cc: Florian Westphal , Pablo Neira Ayuso , David Miller , kadlec , "johannes.berg" , jason , ktkhai , "lucien.xin" , "xiyou.wangcong" , dsahern , netfilter-devel , tom , netdev , linux-kernel Subject: Re: [PATCH] netlink: fix memory leak of dump Message-ID: <20180723105915.a6vx5t7htcclez3k@breakpoint.cc> References: <20180722143354.23722-1-cscnull@gmail.com> <20180722163925.gdfkndldatsoae6x@breakpoint.cc> <20180722.100755.19840167505550163.davem@davemloft.net> <20180722180910.wcwhantwpm2nfxet@breakpoint.cc> <20180723091551.mwhltw4ujm4bylvj@salvia> <20180723092818.ztsfsnqzxgzrauim@breakpoint.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org shaochun chen wrote: > I have a question: we will try_module_get in __netlink_dump_start(), Thats too late, we release rcu read lock before this, so the module implementing ->dump might have been removed already. > but why we need to call try_module_get again in nft_netlink_dump_start ?? Its the other way around. This is the first try_module_get; at this point we still hold rcu read lock. If nf_tables module is being removed, try_module_get will fail and we can error out. If it succeeds, its safe to drop the rcu read lock.