* Check decoding of out-of-range syscalls.
*
* Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2016-2017 The strace developers.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "defs.h"
-#include "syscall.h"
+#include "tests.h"
+#include "sysent.h"
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <asm/unistd.h>
#define TD 0
#define TF 0
#define TP 0
#define TS 0
#define TM 0
+#define TST 0
+#define TLST 0
+#define TFST 0
+#define TSTA 0
+#define TSF 0
+#define TFSF 0
+#define TSFA 0
#define NF 0
#define MA 0
#define SI 0
#define SE 0
-#define SEN(arg) 0,0
+#define CST 0
+#define SEN(arg) 0, 0
static const struct_sysent syscallent[] = {
#include "syscallent.h"
};
-#include <sys/syscall.h>
-
#if defined __X32_SYSCALL_BIT && defined __NR_read \
&& (__X32_SYSCALL_BIT & __NR_read) != 0
# define SYSCALL_BIT __X32_SYSCALL_BIT
# define SYSCALL_BIT 0
#endif
-static const unsigned long nr = ARRAY_SIZE(syscallent) | SYSCALL_BIT;
+static void
+test_syscall(const unsigned long nr)
+{
+ static const kernel_ulong_t a[] = {
+ (kernel_ulong_t) 0xface0fedbadc0dedULL,
+ (kernel_ulong_t) 0xface1fedbadc1dedULL,
+ (kernel_ulong_t) 0xface2fedbadc2dedULL,
+ (kernel_ulong_t) 0xface3fedbadc3dedULL,
+ (kernel_ulong_t) 0xface4fedbadc4dedULL,
+ (kernel_ulong_t) 0xface5fedbadc5dedULL
+ };
+
+ long rc = syscall(nr | SYSCALL_BIT,
+ a[0], a[1], a[2], a[3], a[4], a[5]);
+#ifdef LINUX_MIPSO32
+ printf("syscall(%#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx)"
+ " = %ld ENOSYS (%m)\n", nr | SYSCALL_BIT,
+ a[0], a[1], a[2], a[3], a[4], a[5], rc);
+#else
+ printf("syscall_%lu(%#llx, %#llx, %#llx, %#llx, %#llx, %#llx)"
+ " = %ld (errno %d)\n", nr,
+ (unsigned long long) a[0],
+ (unsigned long long) a[1],
+ (unsigned long long) a[2],
+ (unsigned long long) a[3],
+ (unsigned long long) a[4],
+ (unsigned long long) a[5],
+ rc, errno);
+#endif
+}
int
main(void)
{
- static const unsigned long a[] = {
- (unsigned long) 0xface0fedbadc0ded,
- (unsigned long) 0xface1fedbadc1ded,
- (unsigned long) 0xface2fedbadc2ded,
- (unsigned long) 0xface3fedbadc3ded,
- (unsigned long) 0xface4fedbadc4ded,
- (unsigned long) 0xface5fedbadc5ded
- };
+ test_syscall(ARRAY_SIZE(syscallent));
- long rc = syscall(nr, a[0], a[1], a[2], a[3], a[4], a[5]);
- printf("syscall_%lu(%#lx, %#lx, %#lx, %#lx, %#lx, %#lx)"
- " = %ld (errno %d)\n", nr & (~SYSCALL_BIT),
- a[0], a[1], a[2], a[3], a[4], a[5], rc, errno);
+#ifdef SYS_socket_subcall
+ test_syscall(SYS_socket_subcall + 1);
+#endif
+
+#ifdef SYS_ipc_subcall
+ test_syscall(SYS_ipc_subcall + 1);
+#endif
puts("+++ exited with 0 +++");
return 0;