Re: [PATCH v2] lib: fix bitmap_parse() on 64-bit big endian archs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 8, 2020 at 8:47 PM Alexander Gordeev <agordeev@xxxxxxxxxxxxx> wrote:
>
> Commit 2d6261583be0 ("lib: rework bitmap_parse()") does not
> take into account order of halfwords on 64-bit big endian
> architectures. As result (at least) Receive Packet Steering,
> IRQ affinity masks and runtime kernel test "test_bitmap" get
> broken on s390.

LGTM (I would replace while loop, but it's style preference and one
can consider worse than infinite loop)

Reviewed-by: Andy Shevchenko <andy.shevchenko@xxxxxxxxx>

>
> Fixes: 2d6261583be0 ("lib: rework bitmap_parse()")
> Cc: stable@xxxxxxxxxxxxxxx
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: Yury Norov <yury.norov@xxxxxxxxx>
> Cc: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> Cc: Amritha Nambiar <amritha.nambiar@xxxxxxxxx>
> Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
> Cc: Kees Cook <keescook@xxxxxxxxxxxx>
> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
> Cc: Miklos Szeredi <mszeredi@xxxxxxxxxx>
> Cc: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>
> Cc: Steffen Klassert <steffen.klassert@xxxxxxxxxxx>
> Cc: "Tobin C . Harding" <tobin@xxxxxxxxxx>
> Cc: Vineet Gupta <vineet.gupta1@xxxxxxxxxxxx>
> Cc: Will Deacon <will.deacon@xxxxxxx>
> Cc: Willem de Bruijn <willemb@xxxxxxxxxx>
> Signed-off-by: Alexander Gordeev <agordeev@xxxxxxxxxxxxx>
> ---
>  lib/bitmap.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/lib/bitmap.c b/lib/bitmap.c
> index 89260aa342d6..80d26b183248 100644
> --- a/lib/bitmap.c
> +++ b/lib/bitmap.c
> @@ -739,6 +739,7 @@ int bitmap_parse(const char *start, unsigned int buflen,
>         const char *end = strnchrnul(start, buflen, '\n') - 1;
>         int chunks = BITS_TO_U32(nmaskbits);
>         u32 *bitmap = (u32 *)maskp;
> +       int chunk = 0;
>         int unset_bit;
>
>         while (1) {
> @@ -749,9 +750,14 @@ int bitmap_parse(const char *start, unsigned int buflen,
>                 if (!chunks--)
>                         return -EOVERFLOW;
>
> -               end = bitmap_get_x32_reverse(start, end, bitmap++);
> +#if defined(CONFIG_64BIT) && defined(__BIG_ENDIAN)
> +               end = bitmap_get_x32_reverse(start, end, &bitmap[chunk ^ 1]);
> +#else
> +               end = bitmap_get_x32_reverse(start, end, &bitmap[chunk]);
> +#endif
>                 if (IS_ERR(end))
>                         return PTR_ERR(end);
> +               chunk++;
>         }
>
>         unset_bit = (BITS_TO_U32(nmaskbits) - chunks) * 32;
> --
> 2.23.0
>


-- 
With Best Regards,
Andy Shevchenko



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux