From: Alexander Gordeev <agord...@linux.ibm.com>

commit 81c4f4d924d5d009b5ed785a3e22b18d0f7b831f upstream.

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.

[andriy.shevche...@linux.intel.com: convert infinite while loop to a for loop]
  Link: 
http://lkml.kernel.org/r/20200609140535.87160-1-andriy.shevche...@linux.intel.com

Fixes: 2d6261583be0 ("lib: rework bitmap_parse()")
Signed-off-by: Alexander Gordeev <agord...@linux.ibm.com>
Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
Signed-off-by: Andrew Morton <a...@linux-foundation.org>
Reviewed-by: Andy Shevchenko <andy.shevche...@gmail.com>
Cc: Yury Norov <yury.no...@gmail.com>
Cc: Amritha Nambiar <amritha.namb...@intel.com>
Cc: Arnaldo Carvalho de Melo <a...@redhat.com>
Cc: Chris Wilson <ch...@chris-wilson.co.uk>
Cc: Kees Cook <keesc...@chromium.org>
Cc: Matthew Wilcox <wi...@infradead.org>
Cc: Miklos Szeredi <mszer...@redhat.com>
Cc: Rasmus Villemoes <li...@rasmusvillemoes.dk>
Cc: Steffen Klassert <steffen.klass...@secunet.com>
Cc: "Tobin C . Harding" <to...@kernel.org>
Cc: Vineet Gupta <vineet.gup...@synopsys.com>
Cc: Will Deacon <will.dea...@arm.com>
Cc: Willem de Bruijn <will...@google.com>
Cc: <sta...@vger.kernel.org>
Link: 
http://lkml.kernel.org/r/1591634471-17647-1-git-send-email-agord...@linux.ibm.com
Signed-off-by: Linus Torvalds <torva...@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>

---
 lib/bitmap.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -740,8 +740,9 @@ int bitmap_parse(const char *start, unsi
        int chunks = BITS_TO_U32(nmaskbits);
        u32 *bitmap = (u32 *)maskp;
        int unset_bit;
+       int chunk;
 
-       while (1) {
+       for (chunk = 0; ; chunk++) {
                end = bitmap_find_region_reverse(start, end);
                if (start > end)
                        break;
@@ -749,7 +750,11 @@ int bitmap_parse(const char *start, unsi
                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);
        }


Reply via email to