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: <YshBa/87hSAZwIP3@yury-laptop>
Date:   Fri, 8 Jul 2022 07:38:35 -0700
From:   Yury Norov <yury.norov@...il.com>
To:     Paul Menzel <pmenzel@...gen.mpg.de>
Cc:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] lib/bitmap: Make parameter len unsigned

On Fri, Jul 08, 2022 at 09:52:40AM +0200, Paul Menzel wrote:
> The length is non-negative, so make it unsigned.
> 
> Signed-off-by: Paul Menzel <pmenzel@...gen.mpg.de>

Hi Paul,

Can you please tell more about your motivation for fixing
__bitmap_set? The following __bitmap_clear has the same problem,
and bitmap_parse{,_user}, and bitmap_print_to_pagebuf, and
bitmap_parselist...

Is there a particular problem that is resolved after fixing
__bitmap_set()?

I'm OK if this is a single patch, but for a cleanup work it would 
be more logical to clean everything in a single patch/series...

Thanks,
Yury

> ---
> v2: Update signature in header file
> 
>  include/linux/bitmap.h | 2 +-
>  lib/bitmap.c           | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
> index 2e6cd5681040..feaf84cbc487 100644
> --- a/include/linux/bitmap.h
> +++ b/include/linux/bitmap.h
> @@ -164,7 +164,7 @@ bool __bitmap_intersects(const unsigned long *bitmap1,
>  bool __bitmap_subset(const unsigned long *bitmap1,
>  		     const unsigned long *bitmap2, unsigned int nbits);
>  int __bitmap_weight(const unsigned long *bitmap, unsigned int nbits);
> -void __bitmap_set(unsigned long *map, unsigned int start, int len);
> +void __bitmap_set(unsigned long *map, unsigned int start, unsigned int len);
>  void __bitmap_clear(unsigned long *map, unsigned int start, int len);
>  
>  unsigned long bitmap_find_next_zero_area_off(unsigned long *map,
> diff --git a/lib/bitmap.c b/lib/bitmap.c
> index b18e31ea6e66..0746beb336df 100644
> --- a/lib/bitmap.c
> +++ b/lib/bitmap.c
> @@ -348,14 +348,14 @@ int __bitmap_weight(const unsigned long *bitmap, unsigned int bits)
>  }
>  EXPORT_SYMBOL(__bitmap_weight);
>  
> -void __bitmap_set(unsigned long *map, unsigned int start, int len)
> +void __bitmap_set(unsigned long *map, unsigned int start, unsigned int len)
>  {
>  	unsigned long *p = map + BIT_WORD(start);
>  	const unsigned int size = start + len;
>  	int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);
>  	unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start);
>  
> -	while (len - bits_to_set >= 0) {
> +	while (len >= bits_to_set) {
>  		*p |= mask_to_set;
>  		len -= bits_to_set;
>  		bits_to_set = BITS_PER_LONG;
> -- 
> 2.36.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ