From: Alexey Kodanev <alexey.koda...@oracle.com>
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 <alexey.koda...@oracle.com>
Applied and queued up for -stable, thanks Alexey.