From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-kernel@vger.kernel.org
Cc: Yury Norov <yury.norov@gmail.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH v1 1/1] bitmap: Add test for out-of-boundary modifications for scatter & gather
Date: Thu, 26 Feb 2026 12:16:44 +0100 [thread overview]
Message-ID: <20260226111644.4177742-1-andriy.shevchenko@linux.intel.com> (raw)
Make sure that bitmap_scatter() and bitmap_gather() do not modify
the bits outside of the given nbits span.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
lib/test_bitmap.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
index c83829ef557f..2952a6147e81 100644
--- a/lib/test_bitmap.c
+++ b/lib/test_bitmap.c
@@ -354,18 +354,22 @@ static void __init test_replace(void)
static const unsigned long sg_mask[] __initconst = {
BITMAP_FROM_U64(0x000000000000035aULL),
+ BITMAP_FROM_U64(0x0000000000000000ULL),
};
static const unsigned long sg_src[] __initconst = {
BITMAP_FROM_U64(0x0000000000000667ULL),
+ BITMAP_FROM_U64(0x0000000000000000ULL),
};
static const unsigned long sg_gather_exp[] __initconst = {
BITMAP_FROM_U64(0x0000000000000029ULL),
+ BITMAP_FROM_U64(0x0000000000000000ULL),
};
static const unsigned long sg_scatter_exp[] __initconst = {
BITMAP_FROM_U64(0x000000000000021aULL),
+ BITMAP_FROM_U64(0x0000000000000000ULL),
};
static void __init test_bitmap_sg(void)
@@ -379,18 +383,18 @@ static void __init test_bitmap_sg(void)
/* Simple gather call */
bitmap_zero(bmap_gather, 100);
bitmap_gather(bmap_gather, sg_src, sg_mask, nbits);
- expect_eq_bitmap(sg_gather_exp, bmap_gather, nbits);
+ expect_eq_bitmap(sg_gather_exp, bmap_gather, 100);
/* Simple scatter call */
bitmap_zero(bmap_scatter, 100);
bitmap_scatter(bmap_scatter, sg_src, sg_mask, nbits);
- expect_eq_bitmap(sg_scatter_exp, bmap_scatter, nbits);
+ expect_eq_bitmap(sg_scatter_exp, bmap_scatter, 100);
/* Scatter/gather relationship */
bitmap_zero(bmap_tmp, 100);
bitmap_gather(bmap_tmp, bmap_scatter, sg_mask, nbits);
bitmap_scatter(bmap_res, bmap_tmp, sg_mask, nbits);
- expect_eq_bitmap(bmap_scatter, bmap_res, nbits);
+ expect_eq_bitmap(bmap_scatter, bmap_res, 100);
}
#define PARSE_TIME 0x1
--
2.50.1
reply other threads:[~2026-02-26 11:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260226111644.4177742-1-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--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®