kill13, CVE-2018-10124: Reproduce INT_MIN negation
PATCH 1/1 kill13, CVE-2018-10124: Reproduce INT_MIN negation
--- runtest/cve | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/kill/.gitignore | 1 + testcases/kernel/syscalls/kill/kill13.c | 35 +++++++++++++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 testcases/kernel/syscalls/kill/kill13.c
runtest/cve +1 -0
@@ -49,6 +49,7 @@ cve-2018-5803 sctp_big_chunk cve-2018-7566 snd_seq01 cve-2018-8897 ptrace09 cve-2018-9568 connect02 +cve-2018-10124 kill13 cve-2018-1000001 realpath01 cve-2018-1000199 ptrace08 cve-2018-1000204 ioctl_sg01
runtest/syscalls +1 -0
@@ -644,6 +644,7 @@ kill09 kill09 kill10 kill10 kill11 kill11 kill12 kill12 +kill13 kill13 lchown01 lchown01 lchown01_16 lchown01_16
testcases/kernel/syscalls/kill/.gitignore +1 -0
@@ -8,3 +8,4 @@ /kill10 /kill11 /kill12 +/kill13
testcases/kernel/syscalls/kill/kill13.c new file +35 -0
@@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2021 SUSE LLC <[email protected]> +*/ + +/*\ +* [Description] +* +* Reproducer of CVE-2018-10124; INT_MIN negation. +* +* Most likely this test will always pass without UBSAN +* enabled. Perhaps unless negating INT_MIN results in -1 or +* 0. However on my computer it just results in INT_MIN. +* +*/ + +#include <limits.h> +#include <signal.h> +#include "tst_test.h" + +static void run (void ) +{ +TST_EXP_FAIL2 (kill (INT_MIN ,1000 ),ESRCH , +"kill(INT_MIN, ...) fails with ESRCH" ); +} + +static struct tst_test test = { + .test_all = run, + .taint_check =TST_TAINT_W |TST_TAINT_D , + .tags = (const struct tst_tag []) { + {"linux-git" ,"4ea77014af0d" }, + {"CVE" ,"CVE-2018-10124" }, + {} + } +};
Signature · 1 line
2.31.1
PATCH 1/1 kill13, CVE-2018-10124: Reproduce INT_MIN negation
Quoted 1 line · Richard Palethorpe
Signed-off-by Richard Palethorpe <[email protected]>
Quoted 82 lines
--- runtest/cve | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/kill/.gitignore | 1 + testcases/kernel/syscalls/kill/kill13.c | 35 +++++++++++++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 testcases/kernel/syscalls/kill/kill13.cruntest/cve +1
-0@@ -49,6 +49,7 @@ cve-2018-5803 sctp_big_chunk cve-2018-7566 snd_seq01 cve-2018-8897 ptrace09 cve-2018-9568 connect02 +cve-2018-10124 kill13 cve-2018-1000001 realpath01 cve-2018-1000199 ptrace08 cve-2018-1000204 ioctl_sg01runtest/syscalls +1
-0@@ -644,6 +644,7 @@ kill09 kill09 kill10 kill10 kill11 kill11 kill12 kill12 +kill13 kill13 lchown01 lchown01 lchown01_16 lchown01_16testcases/kernel/syscalls/kill/.gitignore +1
-0@@ -8,3 +8,4 @@ /kill10 /kill11 /kill12 +/kill13testcases/kernel/syscalls/kill/kill13.c new file +35
-0@@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2021 SUSE LLC <[email protected]> +*/ + +/*\ +* [Description] +* +* Reproducer of CVE-2018-10124; INT_MIN negation. +* +* Most likely this test will always pass without UBSAN +* enabled. Perhaps unless negating INT_MIN results in -1 or +* 0. However on my computer it just results in INT_MIN. +* +*/ + +#include <limits.h> +#include <signal.h> +#include "tst_test.h" + +static void run (void ) +{ +TST_EXP_FAIL2 (kill (INT_MIN ,1000 ),ESRCH , +"kill(INT_MIN, ...) fails with ESRCH" ); +} + +static struct tst_test test = { + .test_all = run, + .taint_check =TST_TAINT_W |TST_TAINT_D , + .tags = (const struct tst_tag []) { + {"linux-git" ,"4ea77014af0d" }, + {"CVE" ,"CVE-2018-10124" }, + {} + } +};
Signature · 2 lines
Thank you, Richard.
PATCH 1/1 kill13, CVE-2018-10124: Reproduce INT_MIN negation
In reply to Richard PalethorpeHi Richard,
Quoted 51 lines · Richard Palethorpe via ltp
Signed-off-by Richard Palethorpe <[email protected]>--- runtest/cve | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/kill/.gitignore | 1 + testcases/kernel/syscalls/kill/kill13.c | 35 +++++++++++++++++++++++ 4 files changed, 38 insertions(+)create mode 100644
testcases/kernel/syscalls/kill/kill13.cruntest/cve +1
-0@@ -49,6 +49,7 @@ cve-2018-5803 sctp_big_chunk cve-2018-7566 snd_seq01 cve-2018-8897 ptrace09 cve-2018-9568 connect02 +cve-2018-10124 kill13 cve-2018-1000001 realpath01 cve-2018-1000199 ptrace08 cve-2018-1000204 ioctl_sg01runtest/syscalls +1
-0@@ -644,6 +644,7 @@ kill09 kill09 kill10 kill10 kill11 kill11 kill12 kill12 +kill13 kill13 lchown01 lchown01 lchown01_16 lchown01_16testcases/kernel/syscalls/kill/.gitignore +1
-0@@ -8,3 +8,4 @@ /kill10 /kill11 /kill12 +/kill13testcases/kernel/syscalls/kill/kill13.c new file +3
-0@@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2021 SUSE LLC <[email protected]>
testcases/kernel/syscalls/kill/kill13.c line 13
Quoted 10 lines
testcases/kernel/syscalls/kill/kill13.c new file +10
-0+*/ + +/*\ +* [Description] +* +* Reproducer of CVE-2018-10124; INT_MIN negation. +* +* Most likely this test will always pass without UBSAN +* enabled. Perhaps unless negating INT_MIN results in -1 or +* 0. However on my computer it just results in INT_MIN.
Results in INT_MIN? What does this mean or did you meant to write results in ESRCH?
Default negating int min in two's complement yields 0 (INT_MIN = b1000... and negating means inverting the first bit -> thus 0).
testcases/kernel/syscalls/kill/kill13.c line 24
Quoted 11 lines
testcases/kernel/syscalls/kill/kill13.c new file +11
-0+* +*/ + +#include <limits.h> +#include <signal.h> +#include "tst_test.h" + +static void run (void ) +{ +TST_EXP_FAIL2 (kill (INT_MIN ,1000 ),ESRCH , +"kill(INT_MIN, ...) fails with ESRCH" );
If at some point the kernel decides to change the order of pid and signal validation, it will probably return EINVAL.
Maybe using signal 0 would be better here? It does not "do" anything, but validates the given pid.
Joerg
PATCH 1/1 kill13, CVE-2018-10124: Reproduce INT_MIN negation
Hi,
Quoted 8 lines · Joerg Vehlow
Hi Richard,
Quoted 1 line · Richard Palethorpe via ltp
Results in
INT_MIN? What does this mean or did you meant to write results in ESRCH?
Default negating int min in two's complement yields 0 (INT_MIN= b1000... and negating means inverting the first bit -> thus 0).
Nevermind... Just checked. Looks like somehow x86 keeps -INT_MIN. Now I know what you mean with "results in INT_MIN"
Joerg
PATCH 1/1 kill13, CVE-2018-10124: Reproduce INT_MIN negation
Hello Joerg,
Quoted 7 lines · Joerg Vehlow
Hi,
Quoted 4 lines · Joerg Vehlow
Hi Richard,
Quoted 1 line · Richard Palethorpe via ltp
Quoted 8 lines
Quoted 4 lines
Results in
INT_MIN? What does this mean or did you meant to write results in ESRCH?
Default negating int min in two's complement yields 0 (INT_MIN= b1000... and negating means inverting the first bit -> thus 0).Nevermind... Just checked. Looks like somehow x86 keeps -INT_MIN. Now I know what you mean with "results in
INT_MIN"Joerg
Actually this seems to be expected unless the CPU takes action to prvent it. As you invert all the bits then add one in two's complement. So inverting results in INT_MAX then we add one and overflow back to INT_MIN.
It is undefined though so the CPU could decide to do something else. OTOH it seems quite unlikely we will get anything other than INT_MIN or INT_MAX. So I will set sig number to zero as you suggested and we will just have to rely on UBSAN.
Signature · 2 lines
Thank you, Richard.
PATCH 1/1 kill13, CVE-2018-10124: Reproduce INT_MIN negation
Hi Richard,
Quoted 14 lines · Richard Palethorpe
Hello Joerg,
Quoted 10 lines · Joerg Vehlow
Hi,
Quoted 7 lines · Joerg Vehlow
Hi Richard,
On 7/7/2021 9:18 AM, Richard Palethorpe via ltp wrote:
Results inINT_MIN? What does this mean or did you meant to write results in ESRCH?
Default negating int min in two's complement yields 0 (INT_MIN= b1000... and negating means inverting the first bit -> thus 0).
Quoted 8 lines
Quoted 4 lines
Nevermind... Just checked. Looks like somehow x86 keeps -INT_MIN. Now I know what you mean with "results in
INT_MIN"Joerg
Actually this seems to be expected unless the CPU takes action to prvent it. As you invert all the bits then add one in two's complement. So inverting results in
INT_MAXthen we add one and overflow back toINT_MIN.
Ahh yes totally had the wrong model of * -1 in my head... Of course it is invert everything and add +1.
That of course means -INT_MIN == INT_MIN.
Quoted 5 lines
It is undefined though so the CPU could decide to do something else. OTOH it seems quite unlikely we will get anything other than
INT_MINorINT_MAX. So I will set sig number to zero as you suggested and we will just have to rely on UBSAN.
With this change:
J?rg