[Devel] [PATCH vz9] net/ve: move check if netdevice is allowed in VE

Kirill Tkhai ktkhai at virtuozzo.com
Mon Feb 21 16:06:41 MSK 2022


On 21.02.2022 15:43, Nikita Yushchenko wrote:
> The check if netdevice registration is allowed inside VE uses netdev's
> feature words, that are configured in ndo_init for some netdev types
> (namely, vlan and gre). Move the check below ndo_init, to avoid
> use-before-init scenario.
> 
> Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>

Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>

> ---
>  net/core/dev.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/net/core/dev.c b/net/core/dev.c
> index df8bb05ad4a2..08a1eaa43fe8 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -10299,10 +10299,6 @@ int register_netdevice(struct net_device *dev)
>  	BUG_ON(dev->reg_state != NETREG_UNINITIALIZED);
>  	BUG_ON(!net);
>  
> -	ret = -EPERM;
> -	if (!ve_is_super(net->owner_ve) && ve_is_dev_movable(dev))
> -		return ret;
> -
>  	ret = ethtool_check_ops(dev->ethtool_ops);
>  	if (ret)
>  		return ret;
> @@ -10338,6 +10334,11 @@ int register_netdevice(struct net_device *dev)
>  		}
>  	}
>  
> +	if (!ve_is_super(net->owner_ve) && ve_is_dev_movable(dev)) {
> +		ret = -EPERM;
> +		goto err_uninit;
> +	}
> +
>  	if (((dev->hw_features | dev->features) &
>  	     NETIF_F_HW_VLAN_CTAG_FILTER) &&
>  	    (!dev->netdev_ops->ndo_vlan_rx_add_vid ||
> 



More information about the Devel mailing list