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]
Message-ID: 
 <MW5PR15MB5121C4AE6FF6E7EDB2F5D1DDA4E5A@MW5PR15MB5121.namprd15.prod.outlook.com>
Date: Thu, 31 Aug 2023 15:19:05 +0000
From: Alexander Duyck <alexanderduyck@...a.com>
To: Yinjun Zhang <yinjun.zhang@...igine.com>,
        "mkubecek@...e.cz"
	<mkubecek@...e.cz>
CC: "oss-drivers@...igine.com" <oss-drivers@...igine.com>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        Niklas Söderlund <niklas.soderlund@...igine.com>
Subject: RE: [PATCH ethtool] rxclass: fix a bug in rmgr when searching for
 empty slot

> -----Original Message-----
> From: Yinjun Zhang <yinjun.zhang@...igine.com>
> Sent: Wednesday, August 30, 2023 7:28 PM
> To: mkubecek@...e.cz
> Cc: oss-drivers@...igine.com; netdev@...r.kernel.org; Yinjun Zhang
> <yinjun.zhang@...igine.com>; Alexander Duyck
> <alexanderduyck@...a.com>; Niklas Söderlund
> <niklas.soderlund@...igine.com>
> Subject: [PATCH ethtool] rxclass: fix a bug in rmgr when searching for empty
> slot
> 
> When reverse searching the list in rmgr for a free location the last slot (first
> slot searched) in the list needs special care as it might not span the full word
> length. This is done by building a bit-mask covering the not-active parts of the
> last word and using that to judge if there is a free location in the last word or
> not. Once that is known searching in the last slot, or to skip it, can be done by
> the same algorithm as for the other slots in the list.
> 
> There is a bug in creating the bit-mask for the non-active parts of the last slot
> where the 0-indexed nature of bit addressing is not taken into account when
> shifting. This leads to a one-off bug, fix it.
> 
> Fixes: 8d63f72ccdcb ("Add RX packet classification interface")
> Signed-off-by: Yinjun Zhang <yinjun.zhang@...igine.com>
> Cc: Alexander Duyck <alexanderduyck@...com>
> Reviewed-by: Niklas Söderlund <niklas.soderlund@...igine.com>
> ---
>  rxclass.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/rxclass.c b/rxclass.c
> index 66cf00ba7728..b2471f807d5d 100644
> --- a/rxclass.c
> +++ b/rxclass.c
> @@ -446,7 +446,7 @@ static int rmgr_find_empty_slot(struct rmgr_ctrl
> *rmgr,
>  	 * If loc rolls over it should be greater than or equal to rmgr->size
>  	 * and as such we know we have reached the end of the list.
>  	 */
> -	if (!~(rmgr->slot[slot_num] | (~1UL << rmgr->size %
> BITS_PER_LONG))) {
> +	if (!~(rmgr->slot[slot_num] | (~1UL << (rmgr->size - 1) %
> +BITS_PER_LONG))) {
>  		loc -= 1 + (loc % BITS_PER_LONG);
>  		slot_num--;
>  	}

Rather than use "rmgr->size - 1" you might just use "loc" there since it is the same value. It would also help to make it a bit more obvious that "loc" here represents number of bits from 0 in this slot and that we are assuming 1 bit will always be in play since the mask is ~1UL and not ~0UL.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ