From: Alexander Lobakin <alexandr.lobakin@intel.com>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Yury Norov <yury.norov@gmail.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Michal Swiatkowski <michal.swiatkowski@linux.intel.com>,
Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
Alexander Lobakin <alexandr.lobakin@intel.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 net-next 3/6] lib/test_bitmap: verify intermediate arr32 when converting <-> bitmap
Date: Tue, 18 Oct 2022 16:00:24 +0200 [thread overview]
Message-ID: <20221018140027.48086-4-alexandr.lobakin@intel.com> (raw)
In-Reply-To: <20221018140027.48086-1-alexandr.lobakin@intel.com>
When testing converting bitmaps from/to arr32, use
bitmap_validate_arr32() to test whether the tail of the intermediate
array was cleared correctly. Previously there were checks only for
the actual bitmap generated with the double-conversion.
Note that we pass bitmap_arr32_size() instead of `sizeof(arr)`, as
we poison the bytes past the last used word with 0xa5s. Also, for
@nbits == 0, the validation function must return false, account that
case as well.
Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com>
---
lib/test_bitmap.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
index a8005ad3bd58..c40ab3dfa776 100644
--- a/lib/test_bitmap.c
+++ b/lib/test_bitmap.c
@@ -605,6 +605,7 @@ static void __init test_bitmap_arr32(void)
unsigned int nbits, next_bit;
u32 arr[EXP1_IN_BITS / 32];
DECLARE_BITMAP(bmap2, EXP1_IN_BITS);
+ bool valid;
memset(arr, 0xa5, sizeof(arr));
@@ -620,6 +621,9 @@ static void __init test_bitmap_arr32(void)
" tail is not safely cleared: %d\n",
nbits, next_bit);
+ valid = bitmap_validate_arr32(arr, bitmap_arr32_size(nbits), nbits);
+ expect_eq_uint(!!nbits, valid);
+
if (nbits < EXP1_IN_BITS - 32)
expect_eq_uint(arr[DIV_ROUND_UP(nbits, 32)],
0xa5a5a5a5);
--
2.37.3
next prev parent reply other threads:[~2022-10-18 14:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 14:00 [PATCH v2 net-next 0/6] netlink: add universal 'bigint' attribute type Alexander Lobakin
2022-10-18 14:00 ` [PATCH v2 net-next 1/6] bitmap: try to optimize arr32 <-> bitmap on 64-bit LEs Alexander Lobakin
2022-10-18 22:41 ` Yury Norov
2022-10-19 15:21 ` Alexander Lobakin
2022-10-18 14:00 ` [PATCH v2 net-next 2/6] bitmap: add a couple more helpers to work with arrays of u32s Alexander Lobakin
2022-10-20 0:21 ` Yury Norov
2022-10-20 13:18 ` Andy Shevchenko
2022-10-20 15:31 ` Yury Norov
2022-10-18 14:00 ` Alexander Lobakin [this message]
2022-10-18 14:00 ` [PATCH v2 net-next 4/6] lib/test_bitmap: test the newly added arr32 functions Alexander Lobakin
2022-10-18 14:00 ` [PATCH v2 net-next 5/6] bitops: make BYTES_TO_BITS() treewide-available Alexander Lobakin
2022-10-18 19:55 ` Jakub Kicinski
2022-10-19 15:26 ` Alexander Lobakin
2022-10-18 14:00 ` [PATCH v2 net-next 6/6] netlink: add universal 'bigint' attribute type Alexander Lobakin
2022-10-18 14:13 ` Andy Shevchenko
2022-10-18 19:53 ` Jakub Kicinski
2022-10-19 15:34 ` Alexander Lobakin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221018140027.48086-4-alexandr.lobakin@intel.com \
--to=alexandr.lobakin@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=maciej.fijalkowski@intel.com \
--cc=michal.swiatkowski@linux.intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®