m68k: fix find_next bitops
PATCH 1/1 m68k: fix find_next bitops
find_next bitops on m68k (find_next_zero_bit, find_next_bit, and ext2_find_next_bit) may cause out of bounds memory access when the bitmap size in bits % 32 != 0 and offset (the bitnumber to start searching at) is very close to the bitmap size.
For example,
unsigned long bitmap[2] = { 0, 0 };
find_next_bit(bitmap, 63, 62)1. find_next_bit() tries to find any set bits in bitmap[1], but no bits set.
2. Then find_first_bit(bimap + 2, -1)
3. Unfortunately find_fist_bit() takes unsigned int as the size argument.
4. find_first_bit will access bitmap[2~] until it find any set bits.
This switches find_next bitops to use generic implementation of find bitops to fix the problem.
(Please feel free to suggest alternative way to fix)
Signed-off-by Akinobu Mita <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Roman Zippel <[email protected]>
Cc Andreas Schwab <[email protected]>
Cc Michael Schmitz <[email protected]>
--- arch/m68k/Kconfig | 4 + arch/m68k/include/asm/bitops_mm.h | 188 ++----------------------------------- 2 files changed, 13 insertions(+), 179 deletions(-)
arch/m68k/Kconfig +4 -0
@@ -28,6 +28,10 @@ config GENERIC_HWEIGHT bool default y +config GENERIC_FIND_NEXT_BIT + bool + default y + config GENERIC_CALIBRATE_DELAY bool default y
arch/m68k/include/asm/bitops_mm.h +9 -179
210 lines not on this page · raw message
Signature · 1 line
1.7.4