bitmap_cut() can shift an unused bit from the last storage word
into the valid result. Patch 1 masks the copied tail before
shifting and corrects the existing test expectation. Patch 2
adds checks for partial words and overlapping buffers.
With identical CONFIG_TEST_BITMAP sources and configuration on
x86_64 UML with GCC 13.3.0, the original failed 21 of 391,596
checks and the fixed version passed all 391,596. Clang 18.1.3
compiled both modified objects. A 32-bit kernel and a
Clang-built kernel were not booted.
Jinseob Kim (2):
bitmap: ignore unused tail bits in bitmap_cut()
lib/test_bitmap: cover unused tail bits in bitmap_cut()
lib/bitmap.c | 2 +
lib/test_bitmap.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 93 insertions(+), 2 deletions(-)