Re: "lib: rework bitmap_parse()" triggers invalid access errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 06, 2019 at 12:09:46PM -0400, Qian Cai wrote:
> On Wed, 2019-06-05 at 08:01 +0000, Yuri Norov wrote:
> > (Sorry for top-posting)
> > 
> > I can reproduce this on next-20190604. Is it new trace, or like one you've
> > posted before?
> 
> Same thing, "nbits" causes an invalid access.
> 
> # ./scripts/faddr2line vmlinux bitmap_parse+0x20c/0x2d8
> bitmap_parse+0x20c/0x2d8:
> __bitmap_clear at lib/bitmap.c:280
> (inlined by) bitmap_clear at include/linux/bitmap.h:390
> (inlined by) bitmap_parse at lib/bitmap.c:662
> 
> This line,
> 
> while (len - bits_to_clear >= 0) {

[...]

The problem is in my code, and the fix is:

diff --git a/lib/bitmap.c b/lib/bitmap.c
index ebcf4700ebed..6b3e921f4e91 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -664,7 +664,7 @@ int bitmap_parse(const char *start, unsigned int buflen,
 
 	unset_bit = (BITS_TO_U32(nmaskbits) - chunks) * 32;
 	if (unset_bit < nmaskbits) {
-		bitmap_clear(maskp, unset_bit, nmaskbits);
+		bitmap_clear(maskp, unset_bit, nmaskbits - unset_bit);
 		return 0;
 	}
 
I'll add a test for this case and submit v3 soon.

Yury




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux