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] [day] [month] [year] [list]
Date:   Thu, 3 Jun 2021 21:02:50 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Saeed Mahameed' <saeed@...nel.org>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        Tariq Toukan <tariqt@...dia.com>, Aya Levin <ayal@...dia.com>,
        Saeed Mahameed <saeedm@...dia.com>
Subject: RE: [net 1/8] net/mlx5e: Fix incompatible casting

From: Saeed Mahameed
> Sent: 02 June 2021 02:37
> 
> Device supports setting of a single fec mode at a time, enforce this
> by bitmap_weight == 1. Input from fec command is in u32, avoid cast to
> unsigned long and use bitmap_from_arr32 to populate bitmap safely.
> 
...
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
> b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
> index 8360289813f0..c4724742eef1 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
> @@ -1624,12 +1624,13 @@ static int mlx5e_set_fecparam(struct net_device *netdev,
>  {
>  	struct mlx5e_priv *priv = netdev_priv(netdev);
>  	struct mlx5_core_dev *mdev = priv->mdev;
> +	unsigned long fec_bitmap;
>  	u16 fec_policy = 0;
>  	int mode;
>  	int err;
> 
> -	if (bitmap_weight((unsigned long *)&fecparam->fec,
> -			  ETHTOOL_FEC_LLRS_BIT + 1) > 1)
> +	bitmap_from_arr32(&fec_bitmap, &fecparam->fec, sizeof(fecparam->fec) * BITS_PER_BYTE);
> +	if (bitmap_weight(&fec_bitmap, ETHTOOL_FEC_LLRS_BIT + 1) > 1)
>  		return -EOPNOTSUPP;

What is wrong with:
	if (fecparam->fec & (fecparam->fec - 1))
		return -EOPNOTSUPP;

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ