From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from shards.monkeyblade.net ([184.105.139.130]:33906 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751317AbeBWPst (ORCPT ); Fri, 23 Feb 2018 10:48:49 -0500 Date: Fri, 23 Feb 2018 10:48:47 -0500 (EST) Message-Id: <20180223.104847.2086352429829171963.davem@davemloft.net> To: alexey.kodanev@oracle.com Cc: netdev@vger.kernel.org, gfree.wind@vip.163.com Subject: Re: [PATCH net] macvlan: fix use-after-free in macvlan_common_newlink() From: David Miller In-Reply-To: <1519312830-5601-1-git-send-email-alexey.kodanev@oracle.com> References: <1519312830-5601-1-git-send-email-alexey.kodanev@oracle.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org List-ID: From: Alexey Kodanev Date: Thu, 22 Feb 2018 18:20:30 +0300 > The following use-after-free was reported by KASan when running > LTP macvtap01 test on 4.16-rc2: ... > Commit d02fd6e7d293 ("macvlan: Fix one possible double free") handles > the case when register_netdevice() invokes ndo_uninit() on error and > as a result free the port. But 'macvlan_port_get_rtnl(dev))' check > (returns dev->rx_handler_data), which was added by this commit in order > to prevent double free, is not quite correct: > > * for macvlan it always returns NULL because 'lowerdev' is the one that > was used to register rx handler (port) in macvlan_port_create() as > well as to unregister it in macvlan_port_destroy(). > * for macvtap it always returns a valid pointer because macvtap registers > its own rx handler before macvlan_common_newlink(). > > Fixes: d02fd6e7d293 ("macvlan: Fix one possible double free") > Signed-off-by: Alexey Kodanev Applied and queued up for -stable, thanks Alexey.