Closed rshariffdeen closed 1 year ago
TL;DR: it's the compilation settings, again.
I'm able to reproduce this behavior. I see that during patch validation, the believed exit code is 1, and, like you, when I apply those changes and recompile manually, the exit code is 0.
Edit: The exit code seems to depend on the compilation flags that I use. If I use those used by the patch validation, I also get an exit code 1:
root@03140f4b53cf:/data/vulnloc/coreutils/gnubug-25003/src# make CFLAGS="-ggdb -fPIC -fPIE ${INJECT_CFLAGS}" CXXFLAGS="-ggdb -fPIC -fPIE ${INJECT_CXXFLAGS}" LDFLAGS="${INJECT_LDFLAGS}" src/split
CC src/split.o
clang-6.0: warning: -lkleeRuntest: 'linker' input unused [-Wunused-command-line-argument]
clang-6.0: warning: -lcrepair_runtime: 'linker' input unused [-Wunused-command-line-argument]
clang-6.0: warning: -lcrepair_proxy: 'linker' input unused [-Wunused-command-line-argument]
clang-6.0: warning: -lcrepair_runtime: 'linker' input unused [-Wunused-command-line-argument]
clang-6.0: warning: -lcrepair_proxy: 'linker' input unused [-Wunused-command-line-argument]
clang-6.0: warning: -lkleeRuntest: 'linker' input unused [-Wunused-command-line-argument]
clang-6.0: warning: argument unused during compilation: '-L/klee/build/lib' [-Wunused-command-line-argument]
clang-6.0: warning: argument unused during compilation: '-L/CrashRepair/lib' [-Wunused-command-line-argument]
clang-6.0: warning: argument unused during compilation: '-L/CrashRepair/compiler/../lib/' [-Wunused-command-line-argument]
clang-6.0: warning: argument unused during compilation: '-L/klee/build/lib/' [-Wunused-command-line-argument]
CCLD src/split
root@03140f4b53cf:/data/vulnloc/coreutils/gnubug-25003/src# cd ../
root@03140f4b53cf:/data/vulnloc/coreutils/gnubug-25003# /data/vulnloc/coreutils/gnubug-25003/src/src/split -n7/75 /dev/null; echo $?
hello world!
1
If I don't inject those CFLAGS/CXXFLAGS/LDFLAGS, I get an exit code of 0:
root@03140f4b53cf:/data/vulnloc/coreutils/gnubug-25003/src# make
make all-recursive
make[1]: Entering directory '/data/vulnloc/coreutils/gnubug-25003/src'
Making all in po
make[2]: Entering directory '/data/vulnloc/coreutils/gnubug-25003/src/po'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/data/vulnloc/coreutils/gnubug-25003/src/po'
Making all in .
make[2]: Entering directory '/data/vulnloc/coreutils/gnubug-25003/src'
CC src/split.o
clang-6.0: warning: -lcrepair_runtime: 'linker' input unused [-Wunused-command-line-argument]
clang-6.0: warning: -lcrepair_proxy: 'linker' input unused [-Wunused-command-line-argument]
clang-6.0: warning: -lkleeRuntest: 'linker' input unused [-Wunused-command-line-argument]
clang-6.0: warning: argument unused during compilation: '-L/CrashRepair/compiler/../lib/' [-Wunused-command-line-argument]
clang-6.0: warning: argument unused during compilation: '-L/klee/build/lib/' [-Wunused-command-line-argument]
CCLD src/split
GEN man/split.1
make[2]: Leaving directory '/data/vulnloc/coreutils/gnubug-25003/src'
Making all in gnulib-tests
make[2]: Entering directory '/data/vulnloc/coreutils/gnubug-25003/src/gnulib-tests'
make all-recursive
make[3]: Entering directory '/data/vulnloc/coreutils/gnubug-25003/src/gnulib-tests'
Making all in .
make[4]: Entering directory '/data/vulnloc/coreutils/gnubug-25003/src/gnulib-tests'
make[4]: Nothing to be done for 'all-am'.
make[4]: Leaving directory '/data/vulnloc/coreutils/gnubug-25003/src/gnulib-tests'
make[3]: Leaving directory '/data/vulnloc/coreutils/gnubug-25003/src/gnulib-tests'
make[2]: Leaving directory '/data/vulnloc/coreutils/gnubug-25003/src/gnulib-tests'
make[1]: Leaving directory '/data/vulnloc/coreutils/gnubug-25003/src'
root@03140f4b53cf:/data/vulnloc/coreutils/gnubug-25003/src# /data/vulnloc/coreutils/gnubug-25003/src/src/split -n7/75 /dev/null; echo $?
hello worldz!
0
As soon as I no longer compile with -fsanitize=address
(but otherwise retain all of the other options), the exit code goes to 0. So, for some weird reason, -fsanitize=address
is causing the program to produce an exit code of 1 without printing any kind of error message.
Alright, I got to the bottom of it. ASAN will, by default, produce an exit code of 1 if it detects any sort of memory leak (including false positives). Since we're not making any promises about fixing memory leaks, the simple fix is for the validation step to use detect_leaks=0
in ASAN_OPTIONS
. I'll fix this up now.
Related:
While investigating why no plausible patches for
gnubug-25003
incoreutils
I observed that validation incorrectly removes a correct patch which states that observed exit code is 1 However if I manually apply the patch and run the exploit it exit with code 0