diff options
| author | Bradley Morgan <include@grrlz.net> | 2026-06-21 12:11:33 +0000 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-07-22 21:14:09 -0700 |
| commit | f309b9b364d2a979cac6a1ae3dd25bed79558307 (patch) | |
| tree | 7b7b0820e77404dd4ef7583ce4fc6d5e2230b546 /lib | |
| parent | 695aa786e686f7ae61a7ff2d2a98b98b83680707 (diff) | |
| download | linux-next-f309b9b364d2a979cac6a1ae3dd25bed79558307.tar.gz linux-next-f309b9b364d2a979cac6a1ae3dd25bed79558307.zip | |
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/20260621121133.16460-1-include@grrlz.net
Fixes: 798248206b59 ("lib/string.c: introduce memchr_inv()")
Signed-off-by: Bradley Morgan <include@grrlz.net>
Cc: Akinbou Mita <akinobu.mita@gmail.com>
Cc: Andy Shevchenko <andy@kernel.org>
Cc: Christoph Lameer <cl@linux-foundation.org>
Cc: Joern Engel <joern@logfs.org>
Cc: Kees Cook <kees@kernel.org>
Cc: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/string.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/string.c b/lib/string.c index a4e8ad23577d..a3778d5aab4a 100644 --- a/lib/string.c +++ b/lib/string.c @@ -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); |
