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