lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Mon, 7 Jul 2014 16:20:08 -0700 From: Andrew Morton <akpm@...ux-foundation.org> To: Rasmus Villemoes <linux@...musvillemoes.dk> Cc: linux-kernel@...r.kernel.org Subject: Re: [PATCH 00/18] lib: bitmap: Various improvements On Fri, 4 Jul 2014 00:42:46 +0200 Rasmus Villemoes <linux@...musvillemoes.dk> wrote: > Many functions in lib/bitmap.c start with an expression such as lim = > bits/BITS_PER_LONG. Since bits has type (signed) int, and since gcc > cannot know that it is in fact non-negative, it generates worse code > than it could. These patches, mostly consisting of changing various > parameters to unsigned, gives a slight overall code reduction: Yes, we have a bad habit of using signed types for things where negative values are absurd. The patches look OK to me. > A few issues I thought about, but didn't know what to do with: > > * Many of the functions misbehave if nbits is compile-time 0; the > out-of-line functions generally handle 0 correctly. bitmap_fill() is > particularly bad, whether the 0 is known at compile time or not. It > would probably be nice to add detection of at least compile-time 0 > and handle that appropriately. The best option here would be a compile-time check. Presumably BUILD_BUG_ON(). That will catch the errant use and will add no runtime overhead. > * I didn't change __bitmap_shift_{left,right} to use unsigned because > I want to fully understand why the algorithm works before making > that change. However, AFAICT, they behave correctly for all > (positive) shift amounts. This is not the case for the > small_const_nbits versions. If for example nbits = n = > BITS_PER_LONG, the shift operators turn into no-ops (at least on > x86), so one get *dst = *src, whereas one would expect to get > *dst=0. That difference in behaviour is somewhat annoying. yup. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@...r.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists