1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
/*
* Check decoding of invalid pointer by umoven.
*
* Copyright (c) 2016-2018 Dmitry V. Levin <ldv@strace.io>
* Copyright (c) 2016-2021 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "tests.h"
#include "scno.h"
#ifdef __NR_nanosleep
# include <stdio.h>
# include <unistd.h>
# include "kernel_old_timespec.h"
static const char *errstr;
static long
k_nanosleep(const kernel_ulong_t arg1, const kernel_ulong_t arg2)
{
const kernel_ulong_t bad = (kernel_ulong_t) 0xbadc0dedbadc0dedULL;
const long rc = syscall(__NR_nanosleep, arg1, arg2, bad, bad, bad, bad);
errstr = sprintrc(rc);
return rc;
}
int
main(void)
{
if (!F8ILL_KULONG_SUPPORTED)
return 77;
kernel_old_timespec_t ts = { 0, 0 };
const void *const p = tail_memdup(&ts, sizeof(ts));
k_nanosleep((unsigned long) p, 0);
printf("nanosleep({tv_sec=0, tv_nsec=0}, NULL) = %s\n", errstr);
const kernel_ulong_t ill = f8ill_ptr_to_kulong(p);
k_nanosleep(ill, 0);
printf("nanosleep(%#llx, NULL) = %s\n",
(unsigned long long) ill, errstr);
puts("+++ exited with 0 +++");
return 0;
}
#else
SKIP_MAIN_UNDEFINED("__NR_nanosleep")
#endif
|