linux-stable/tools/include
Rasmus Villemoes 91e72fe195 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:17:33 +01:00
..
asm nds32: Remove the architecture 2022-03-07 13:54:59 +01:00
asm-generic bitops: wrap non-atomic bitops with a transparent macro 2022-06-30 19:52:41 -07:00
linux tools: fix compilation after gfp_types.h split 2022-09-11 16:22:31 -07:00
nolibc tools/nolibc/string: Fix memcmp() implementation 2022-11-10 18:17:33 +01:00
tools tools include: add dis-asm-compat.h to handle version differences 2022-08-01 15:29:49 -03:00
trace/events
uapi bpf, cgroup: Reject prog_attach_flags array when effective query 2022-10-21 12:38:11 +02:00
vdso tools headers: Synchronize linux/bits.h with the kernel sources 2020-04-14 11:40:05 -03:00