1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) 2021 SUSE LLC <rpalethorpe@suse.com>
4 */
5
6 /*\
7 * [Description]
8 *
9 * Check wait4(INT_MIN, ...) is not allowed. The pid is negated before
10 * searching for a group with that pid. Negating INT_MIN is not
11 * defined so UBSAN will be triggered if enabled. Also see kill13.
12 *
13 * If the bug is present, but UBSAN is not enabled, then it should
14 * result in ECHILD.
15 */
16
17 #include <stdlib.h>
18 #include <errno.h>
19 #include <limits.h>
20 #define _USE_BSD
21 #include <sys/types.h>
22 #include <sys/resource.h>
23 #include <sys/wait.h>
24 #include "tst_test.h"
25
run(void)26 static void run(void)
27 {
28 int status = 1;
29 struct rusage rusage;
30
31 TST_EXP_FAIL2(wait4(INT_MIN, &status, 0, &rusage), ESRCH,
32 "wait4 fails with ESRCH");
33 }
34
35 static struct tst_test test = {
36 .test_all = run,
37 .taint_check = TST_TAINT_W | TST_TAINT_D,
38 .tags = (const struct tst_tag[]) {
39 {"linux-git", "dd83c161fbcc"},
40 {}
41 }
42 };
43