mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
lib/string: fix memchr_inv() for large ranges
memchr_inv() takes a size_t length but counts 8 byte words in an unsigned
int. At 32GiB that count wraps, so the scan can quietly miss most of the
range.
Use size_t for the word count.
Link: https://lore.kernel.org/[email protected]
Fixes: 798248206b ("lib/string.c: introduce memchr_inv()")
Signed-off-by: Bradley Morgan <[email protected]>
Cc: Akinbou Mita <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: Christoph Lameer <[email protected]>
Cc: Joern Engel <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Pekka Enberg <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
This commit is contained in:
committed by
Andrew Morton
parent
2fdf181afd
commit
c04cffb8c5
+2
-1
@@ -821,7 +821,8 @@ void *memchr_inv(const void *start, int c, size_t bytes)
|
||||
{
|
||||
u8 value = c;
|
||||
u64 value64;
|
||||
unsigned int words, prefix;
|
||||
size_t words;
|
||||
unsigned int prefix;
|
||||
|
||||
if (bytes <= 16)
|
||||
return check_bytes8(start, value, bytes);
|
||||
|
||||
Reference in New Issue
Block a user