Kees Cook
aca7e5b6a5
libsubcmd: Fix use-after-free for realloc(..., 0)
commit 52a9dab6d892763b2a8334a568bd4e2c1a6fde66 upstream.
GCC 12 correctly reports a potential use-after-free condition in the
xrealloc helper. Fix the warning by avoiding an implicit "free(ptr)"
when size == 0:
In file included from help.c:12:
In function 'xrealloc',
inlined from 'add_cmdname' at help.c:24:2: subcmd-util.h:56:23: error: pointer may be used after 'realloc' [-Werror=use-after-free]
56 | ret = realloc(ptr, size);
| ^~~~~~~~~~~~~~~~~~
subcmd-util.h:52:21: note: call to 'realloc' here
52 | void *ret = realloc(ptr, size);
| ^~~~~~~~~~~~~~~~~~
subcmd-util.h:58:31: error: pointer may be used after 'realloc' [-Werror=use-after-free]
58 | ret = realloc(ptr, 1);
| ^~~~~~~~~~~~~~~
subcmd-util.h:52:21: note: call to 'realloc' here
52 | void *ret = realloc(ptr, size);
| ^~~~~~~~~~~~~~~~~~
Fixes: 2f4ce5ec1d ("perf tools: Finalize subcmd independence")
Reported-by: Valdis Klētnieks <[email protected]>
Signed-off-by: Kees Kook <[email protected]>
Tested-by: Valdis Klētnieks <[email protected]>
Tested-by: Justin M. Forbes <[email protected]>
Acked-by: Josh Poimboeuf <[email protected]>
Cc: [email protected]
Cc: Valdis Klētnieks <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
2022-02-23 11:59:58 +01:00 |
| .. |
|
accounting
|
|
|
|
arch
|
ia64: tools: remove duplicate definition of ia64_mf() on ia64
|
2021-04-28 13:19:16 +02:00 |
|
bpf
|
bpftool: Remove inclusion of utilities.mak from Makefiles
|
2022-01-27 09:19:53 +01:00 |
|
build
|
tools build: Remove needless libpython-version feature check that breaks test-all fast path
|
2021-12-14 14:49:03 +01:00 |
|
cgroup
|
|
|
|
debugging
|
|
|
|
firewire
|
|
|
|
firmware
|
|
|
|
gpio
|
tools: gpio-hammer: Avoid potential overflow in main
|
2020-10-01 13:17:47 +02:00 |
|
hv
|
|
|
|
iio
|
|
|
|
include
|
tools/nolibc: fix incorrect truncation of exit code
|
2022-01-27 09:19:27 +01:00 |
|
io_uring
|
tools/io_uring: fix compile breakage
|
2020-10-07 08:01:27 +02:00 |
|
kvm/kvm_stat
|
|
|
|
laptop
|
|
|
|
leds
|
|
|
|
lib
|
libsubcmd: Fix use-after-free for realloc(..., 0)
|
2022-02-23 11:59:58 +01:00 |
|
memory-model
|
|
|
|
nfsd
|
|
|
|
objtool
|
objtool: Fix ".cold" section suffix check for newer versions of GCC
|
2021-03-04 10:26:30 +01:00 |
|
pci
|
|
|
|
pcmcia
|
|
|
|
perf
|
perf probe: Fix ppc64 'perf probe add events failed' case
|
2022-02-16 12:52:50 +01:00 |
|
power
|
tweewide: Fix most Shebang lines
|
2021-05-22 11:38:30 +02:00 |
|
scripts
|
tools: Allow proper CC/CXX/... override with LLVM=1 in Makefile.include
|
2021-07-31 08:19:37 +02:00 |
|
spi
|
|
|
|
testing
|
selftests/zram: Adapt the situation that /dev/zram0 is being used
|
2022-02-23 11:59:55 +01:00 |
|
thermal/tmon
|
tools/thermal/tmon: Add cross compiling support
|
2021-09-22 12:26:20 +02:00 |
|
time
|
|
|
|
usb
|
usb: testusb: Fix for showing the connection speed
|
2021-10-09 14:39:49 +02:00 |
|
virtio
|
|
|
|
vm
|
tools/vm/page-types: remove dependency on opt_file for idle page tracking
|
2021-10-09 14:39:50 +02:00 |
|
wmi
|
|
|
|
Makefile
|
|
|