Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5603830imm; Mon, 23 Jul 2018 02:44:14 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcMmz3Sup2hFmJj0RhDJ6wnAQ4v3fsFVRpQ4YKRh0EVKskRkn4eF65QX6iaBEg5IXCuHtgV X-Received: by 2002:a17:902:24e:: with SMTP id 72-v6mr6905247plc.74.1532339054578; Mon, 23 Jul 2018 02:44:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532339054; cv=none; d=google.com; s=arc-20160816; b=bObxumHYFYKmZuaHwKddT5UB29ztkSThgUtQHulF+P6DxfyGAn0U4/q/8YgEylxquH rCpO1a7NaWPBgmECPigy3IlqRSTL+9E9thRBiNlbDVBbfePwec9F5zQVdvM606EqH9yv qmHLeAibOfnmRj3nMnW4DCsJyl/wOoxOBt40meNW7z1iEdrszVafES9OYjvAhswKjYJS CqulE2yRvCtuv58b2Z17mANLAXt3zoZCUV/NO0ylzTW0phn+ONHoYnoYWXo+tjLr3uIq x0tRLLx3u9oE/okne34JpxrFzZekhOAkwJqIivpPwsvIIrnYCx21eoKFMtIsRley6I6m XbEQ== 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=yZy/HWLMwKjDbV5wtpe1aEl4LKemwdoYmaxnPBfivys=; b=0GJLjNSJFvfbxOXgx0Dc77OK5hUFQNqilki2VrhpoF3msnXqqG7EbpA/mWOikjMzTq E4NUiqNGoMXynSDbWbMjhX3cu8+i5LCYYhCBjxlZsjrtejhqSrNwaPz5kH08QDVGJ/I3 KjPubPKw+fAbi73rqig8BLTpwMb+HVxtM7P//4dTVR4hPzrgelPSe2p2zDQ7lXOQHyCr 6yAl2eMmyeNMVXDpD/Mx/pTq8iVi8sA413uOw9MFeUrm1ymXOWcqZvqtgCALsSplYW34 HuKtPhx4qLOmbioww1asY5Xh0tDgt8g6XrU5yXBi8NsDd36QvIVO8OB204pSw18xr/9d i1QQ== 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 t2-v6si8494809pgg.422.2018.07.23.02.44.00; Mon, 23 Jul 2018 02:44:14 -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 S2388302AbeGWKm4 (ORCPT + 99 others); Mon, 23 Jul 2018 06:42:56 -0400 Received: from Chamillionaire.breakpoint.cc ([146.0.238.67]:35178 "EHLO Chamillionaire.breakpoint.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388180AbeGWKmz (ORCPT ); Mon, 23 Jul 2018 06:42:55 -0400 Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.89) (envelope-from ) id 1fhXMK-0007tg-Fd; Mon, 23 Jul 2018 11:42:28 +0200 Date: Mon, 23 Jul 2018 11:42:28 +0200 From: Florian Westphal To: Pablo Neira Ayuso Cc: Florian Westphal , David Miller , cscnull@gmail.com, kadlec@blackhole.kfki.hu, johannes.berg@intel.com, Jason@zx2c4.com, ktkhai@virtuozzo.com, lucien.xin@gmail.com, xiyou.wangcong@gmail.com, dsahern@gmail.com, netfilter-devel@vger.kernel.org, tom@quantonium.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] netlink: fix memory leak of dump Message-ID: <20180723094228.mejwuvoyitolqktv@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> <20180723093855.c4ncixsnkee6r34v@salvia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180723093855.c4ncixsnkee6r34v@salvia> 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 Pablo Neira Ayuso wrote: > > As David pointed out, once ->start() returns 0 we set cb_running, i.e. > > only after successful ->start() netlink core will call ->dump() again. > > > > So I see no problem setting ->data to onstack cookie and then > > duplicating it to heap via kmemdup in ->start(). > > > > As far as I can see netlink core offers all functionality already, > > so we only need to switch netfilter to make use of it. > > > > If you disagree please let me know, otherwise I will cook up > > a patch along this pattern for net/netfilter/*. > > Why not just call ->done from netlink_dump_start() when it fails? Not sure thats safe for all users, we will also still need to call it in nft_netlink_dump_start and we need to play guess game wrt EINTR (which can mean 'dump was now started, do not send ack').