From patchwork Mon Jun 8 23:43:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 224729 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C604EC433E0 for ; Mon, 8 Jun 2020 23:43:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C6CE20659 for ; Mon, 8 Jun 2020 23:43:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591659822; bh=ggPZuuhjSRGM7zE7zXP/zWIFiCo7SNBnhpwJ3wfZQFU=; h=Date:From:To:Subject:In-Reply-To:List-ID:From; b=wiwU7eyhuB0o4Cldu2xPwFjM3RJvrIhSY8+fB5UmgEpzPQnpSEqTEsbKf1IGGiEqf egkJdSEcu6kofzSF5wgUrFj54dsIM1auPejplePoJxIc5i74pMGoVhXDZdqUdoJpj3 r+uHk/9E6xrjR6wXmwZ9OOGDEcceqEcJUDYoKgGA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387889AbgFHXni (ORCPT ); Mon, 8 Jun 2020 19:43:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:49694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387667AbgFHXnh (ORCPT ); Mon, 8 Jun 2020 19:43:37 -0400 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C28012078C; Mon, 8 Jun 2020 23:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591659816; bh=ggPZuuhjSRGM7zE7zXP/zWIFiCo7SNBnhpwJ3wfZQFU=; h=Date:From:To:Subject:In-Reply-To:From; b=PpD7Ew+6wXPOLcQ8M58cxscQ0mBKy1LNI/UV23Klf/NVIJmVoF0nkVbefAF1JXF8z BEEmH+Y/LyfRGUYzp9ubilSB+VVyGy7HqnntfZFEf+zb6GOYhl1xWqF3UvT+HvAed9 F/AwJj7hJon99QS4BFMKZKCJYse5IqAptspNU4nI= Date: Mon, 08 Jun 2020 16:43:35 -0700 From: Andrew Morton To: acme@redhat.com, agordeev@linux.ibm.com, amritha.nambiar@intel.com, andriy.shevchenko@linux.intel.com, chris@chris-wilson.co.uk, keescook@chromium.org, linux@rasmusvillemoes.dk, mm-commits@vger.kernel.org, mszeredi@redhat.com, stable@vger.kernel.org, steffen.klassert@secunet.com, tobin@kernel.org, vineet.gupta1@synopsys.com, will.deacon@arm.com, willemb@google.com, willy@infradead.org, yury.norov@gmail.com Subject: + lib-fix-bitmap_parse-on-64-bit-big-endian-archs.patch added to -mm tree Message-ID: <20200608234335.ip8WJ3NXZ%akpm@linux-foundation.org> In-Reply-To: <20200607212615.b050e41fac139a1e16fe00bd@linux-foundation.org> User-Agent: s-nail v14.8.16 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch titled Subject: lib: fix bitmap_parse() on 64-bit big endian archs has been added to the -mm tree. Its filename is lib-fix-bitmap_parse-on-64-bit-big-endian-archs.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/lib-fix-bitmap_parse-on-64-bit-big-endian-archs.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/lib-fix-bitmap_parse-on-64-bit-big-endian-archs.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Alexander Gordeev Subject: lib: fix bitmap_parse() on 64-bit big endian archs 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. Link: http://lkml.kernel.org/r/1591634471-17647-1-git-send-email-agordeev@linux.ibm.com Fixes: 2d6261583be0 ("lib: rework bitmap_parse()") Signed-off-by: Alexander Gordeev Cc: Yury Norov Cc: Andy Shevchenko Cc: Amritha Nambiar Cc: Arnaldo Carvalho de Melo Cc: Chris Wilson Cc: Kees Cook Cc: Matthew Wilcox Cc: Miklos Szeredi Cc: Rasmus Villemoes Cc: Steffen Klassert Cc: "Tobin C . Harding" Cc: Vineet Gupta Cc: Will Deacon Cc: Willem de Bruijn Cc: Signed-off-by: Andrew Morton --- lib/bitmap.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/lib/bitmap.c~lib-fix-bitmap_parse-on-64-bit-big-endian-archs +++ a/lib/bitmap.c @@ -740,6 +740,7 @@ int bitmap_parse(const char *start, unsi 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) { @@ -750,9 +751,14 @@ 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); + chunk++; } unset_bit = (BITS_TO_U32(nmaskbits) - chunks) * 32;