lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200906072759.GC55261@unreal>
Date:   Sun, 6 Sep 2020 10:27:59 +0300
From:   Leon Romanovsky <leon@...nel.org>
To:     Jakub Kicinski <kuba@...nel.org>
Cc:     davem@...emloft.net, netdev@...r.kernel.org, kernel-team@...com,
        tariqt@...lanox.com, yishaih@...lanox.com,
        linux-rdma@...r.kernel.org, jiri@...nulli.us
Subject: Re: [PATCH net-next] mlx4: make sure to always set the port type

On Fri, Sep 04, 2020 at 01:06:21PM -0700, Jakub Kicinski wrote:
> Even tho mlx4_core registers the devlink ports, it's mlx4_en
> and mlx4_ib which set their type. In situations where one of
> the two is not built yet the machine has ports of given type
> we see the devlink warning from devlink_port_type_warn() trigger.
>
> Having ports of a type not supported by the kernel may seem
> surprising, but it does occur in practice - when the unsupported
> port is not plugged in to a switch anyway users are more than happy
> not to see it (and potentially allocate any resources to it).
>
> Set the type in mlx4_core if type-specific driver is not built.
>
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> ---
>  drivers/net/ethernet/mellanox/mlx4/main.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
> index 258c7a96f269..70cf24ba71e4 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/main.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/main.c
> @@ -3031,6 +3031,17 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
>  	if (err)
>  		return err;
>
> +	/* Ethernet and IB drivers will normally set the port type,
> +	 * but if they are not built set the type now to prevent
> +	 * devlink_port_type_warn() from firing.
> +	 */
> +	if (!IS_ENABLED(CONFIG_MLX4_EN) &&
> +	    dev->caps.port_type[port] == MLX4_PORT_TYPE_ETH)
> +		devlink_port_type_eth_set(&info->devlink_port, NULL);
                                                               ^^^^^

Won't it crash in devlink_port_type_eth_set()?
The first line there dereferences pointer.
  7612         const struct net_device_ops *ops = netdev->netdev_ops;

And can we call to devlink_port_type_*_set() without IS_ENABLED() check?

Thanks


> +	else if (!IS_ENABLED(CONFIG_MLX4_INFINIBAND) &&
> +		 dev->caps.port_type[port] == MLX4_PORT_TYPE_IB)
> +		devlink_port_type_ib_set(&info->devlink_port, NULL);
> +
>  	info->dev = dev;
>  	info->port = port;
>  	if (!mlx4_is_slave(dev)) {
> --
> 2.26.2
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ