* Check decoding of ptrace syscall.
*
* Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
- * Copyright (c) 2016-2017 The strace developers.
+ * Copyright (c) 2016-2018 The strace developers.
* All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "tests.h"
#include <asm/unistd.h>
#include <errno.h>
+#include "ptrace.h"
+#include <inttypes.h>
#include <signal.h>
+#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
-#include "ptrace.h"
#include <linux/audit.h>
static const char *errstr;
printf("ptrace(PTRACE_PEEKSIGINFO, %u, NULL, %#lx) = %s\n",
(unsigned) pid, bad_request, errstr);
- struct {
+ struct psi {
unsigned long long off;
unsigned int flags, nr;
- } *const psi = tail_alloc(sizeof(*psi));
+ };
+ TAIL_ALLOC_OBJECT_CONST_PTR(struct psi, psi);
psi->off = 0xdeadbeeffacefeedULL;
psi->flags = 1;
if (errno == EINTR)
continue;
saved = errno;
- kill (pid, SIGKILL);
+ kill(pid, SIGKILL);
errno = saved;
perror_msg_and_fail("wait");
}
if (do_ptrace(PTRACE_CONT, pid, 0, 0)) {
saved = errno;
- kill (pid, SIGKILL);
+ kill(pid, SIGKILL);
errno = saved;
perror_msg_and_fail("ptrace");
}
- printf("ptrace(PTRACE_CONT, %ld, NULL, SIG_0) = 0\n", pid);
+ printf("ptrace(PTRACE_CONT, %ld, NULL, 0) = 0\n", pid);
}
}
const unsigned long pid =
(unsigned long) 0xdefaced00000000ULL | (unsigned) getpid();
+ TAIL_ALLOC_OBJECT_CONST_PTR(uint64_t, filter_off);
+
const unsigned int sigset_size = get_sigset_size();
void *const k_set = tail_alloc(sigset_size);
printf("ptrace(PTRACE_SECCOMP_GET_FILTER, %u, 42, NULL) = %s\n",
(unsigned) pid, errstr);
+ do_ptrace(PTRACE_SECCOMP_GET_METADATA, pid, bad_data, 0);
+ printf("ptrace(PTRACE_SECCOMP_GET_METADATA, %u, %lu, NULL) = %s\n",
+ (unsigned) pid, bad_data, errstr);
+
+ do_ptrace(PTRACE_SECCOMP_GET_METADATA, pid, 7,
+ (unsigned long) filter_off);
+ printf("ptrace(PTRACE_SECCOMP_GET_METADATA, %u, 7, %p) = %s\n",
+ (unsigned) pid, filter_off, errstr);
+
+ *filter_off = 0xfacefeeddeadc0deULL;
+ do_ptrace(PTRACE_SECCOMP_GET_METADATA, pid, bad_data,
+ (unsigned long) filter_off);
+ printf("ptrace(PTRACE_SECCOMP_GET_METADATA, %u, %lu, "
+ "{filter_off=%" PRIu64 "}) = %s\n",
+ (unsigned) pid, bad_data, *filter_off, errstr);
+
do_ptrace(PTRACE_GETEVENTMSG, pid, bad_request, bad_data);
printf("ptrace(PTRACE_GETEVENTMSG, %u, %#lx, %#lx) = %s\n",
(unsigned) pid, bad_request, bad_data, errstr);