linux/tools/include
Rasmus Villemoes 27b4406f9c tools/nolibc/string: Fix memcmp() implementation
commit b3f4f51ea6 upstream.

The C standard says that memcmp() must treat the buffers as consisting
of "unsigned chars". If char happens to be unsigned, the casts are ok,
but then obviously the c1 variable can never contain a negative
value. And when char is signed, the casts are wrong, and there's still
a problem with using an 8-bit quantity to hold the difference, because
that can range from -255 to +255.

For example, assuming char is signed, comparing two 1-byte buffers,
one containing 0x00 and another 0x80, the current implementation would
return -128 for both memcmp(a, b, 1) and memcmp(b, a, 1), whereas one
of those should of course return something positive.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Fixes: 66b6f755ad ("rcutorture: Import a copy of nolibc")
Cc: stable@vger.kernel.org # v5.0+
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-11-10 18:15:38 +01:00
..
asm tools arch: Update arch/x86/lib/mem{cpy,set}_64.S copies used in 'perf bench mem memcpy' 2021-05-10 09:01:00 -03:00
asm-generic x86/insn: Use get_unaligned() instead of memcpy() 2021-11-18 19:16:30 +01:00
linux objtool: Re-add UNWIND_HINT_{SAVE_RESTORE} 2022-07-23 12:54:08 +02:00
nolibc tools/nolibc/string: Fix memcmp() implementation 2022-11-10 18:15:38 +01:00
tools tools: bpf: fix license for a compat header file 2018-09-19 23:49:58 +02:00
trace/events
uapi tools/include/uapi: Fix <asm/errno.h> for parisc and xtensa 2022-09-23 14:15:49 +02:00
vdso tools headers: Synchronize linux/bits.h with the kernel sources 2020-04-14 11:40:05 -03:00