import strace-5.7-2.1.el8_4
This commit is contained in:
parent
884e5658e4
commit
34ac6c3594
1102
SOURCES/0142-tests-add-fchmod-y-test.patch
Normal file
1102
SOURCES/0142-tests-add-fchmod-y-test.patch
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,795 @@
|
||||
From e244ae965b17280313d92baef71165efc00ac51b Mon Sep 17 00:00:00 2001
|
||||
From: "Dmitry V. Levin" <ldv@altlinux.org>
|
||||
Date: Sat, 4 Jul 2020 08:00:00 +0000
|
||||
Subject: [PATCH 144/149] tests: check decoding of faccessat syscall in -P, -y,
|
||||
and -yy modes
|
||||
|
||||
* tests/faccessat.c: Rewrite.
|
||||
* tests/faccessat-P.c: New file.
|
||||
* tests/faccessat-y.c: Likewise.
|
||||
* tests/faccessat-yy.c: Likewise.
|
||||
* tests/faccessat.test: New test.
|
||||
* tests/Makefile.am (DECODER_TESTS): Add faccessat.test.
|
||||
* tests/gen_tests.in (faccessat): Remove.
|
||||
(faccessat-P, faccessat-y, faccessat-yy): New entries.
|
||||
* tests/pure_executables.list: Add faccessat-P, faccessat-y,
|
||||
and faccessat-yy.
|
||||
* tests/.gitignore: Likewise.
|
||||
---
|
||||
tests/.gitignore | 3 ++
|
||||
tests/Makefile.am | 1 +
|
||||
tests/faccessat-P.c | 4 ++
|
||||
tests/faccessat-y.c | 4 ++
|
||||
tests/faccessat-yy.c | 4 ++
|
||||
tests/faccessat.c | 127 ++++++++++++++++++++++++++++++++++++++++++--
|
||||
tests/faccessat.test | 19 +++++++
|
||||
tests/gen_tests.in | 4 +-
|
||||
tests/pure_executables.list | 3 ++
|
||||
9 files changed, 163 insertions(+), 6 deletions(-)
|
||||
create mode 100644 tests/faccessat-P.c
|
||||
create mode 100644 tests/faccessat-y.c
|
||||
create mode 100644 tests/faccessat-yy.c
|
||||
create mode 100755 tests/faccessat.test
|
||||
|
||||
Index: strace-5.7/tests/Makefile.am
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests/Makefile.am 2021-08-24 19:42:16.041519983 +0200
|
||||
+++ strace-5.7/tests/Makefile.am 2021-08-24 19:46:08.275554370 +0200
|
||||
@@ -346,6 +346,7 @@
|
||||
execve-v.test \
|
||||
execve.test \
|
||||
fadvise64.test \
|
||||
+ faccessat.test \
|
||||
futex.test \
|
||||
getuid.test \
|
||||
int_0x80.test \
|
||||
Index: strace-5.7/tests/faccessat-P.c
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ strace-5.7/tests/faccessat-P.c 2021-08-24 19:46:08.275554370 +0200
|
||||
@@ -0,0 +1,4 @@
|
||||
+#define PATH_TRACING
|
||||
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
|
||||
+
|
||||
+#include "faccessat.c"
|
||||
Index: strace-5.7/tests/faccessat-y.c
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ strace-5.7/tests/faccessat-y.c 2021-08-24 19:46:08.276554362 +0200
|
||||
@@ -0,0 +1,4 @@
|
||||
+#define FD_PATH "</dev/full>"
|
||||
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
|
||||
+
|
||||
+#include "faccessat.c"
|
||||
Index: strace-5.7/tests/faccessat-yy.c
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ strace-5.7/tests/faccessat-yy.c 2021-08-24 19:46:08.276554362 +0200
|
||||
@@ -0,0 +1,4 @@
|
||||
+#define FD_PATH "</dev/full<char 1:7>>"
|
||||
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
|
||||
+
|
||||
+#include "faccessat.c"
|
||||
Index: strace-5.7/tests/faccessat.c
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests/faccessat.c 2021-08-24 17:01:53.365934740 +0200
|
||||
+++ strace-5.7/tests/faccessat.c 2021-08-24 19:46:08.277554353 +0200
|
||||
@@ -1,4 +1,6 @@
|
||||
/*
|
||||
+ * Check decoding of faccessat syscall.
|
||||
+ *
|
||||
* Copyright (c) 2016-2019 The strace developers.
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -10,18 +12,133 @@
|
||||
|
||||
#ifdef __NR_faccessat
|
||||
|
||||
+# include <fcntl.h>
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
|
||||
+# ifndef FD_PATH
|
||||
+# define FD_PATH ""
|
||||
+# endif
|
||||
+# ifndef SKIP_IF_PROC_IS_UNAVAILABLE
|
||||
+# define SKIP_IF_PROC_IS_UNAVAILABLE
|
||||
+# endif
|
||||
+
|
||||
+static const char *errstr;
|
||||
+
|
||||
+static long
|
||||
+k_faccessat(const unsigned int dirfd,
|
||||
+ const void *const pathname,
|
||||
+ const unsigned int mode)
|
||||
+{
|
||||
+ const kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
|
||||
+ const kernel_ulong_t bad = (kernel_ulong_t) 0xbadc0dedbadc0dedULL;
|
||||
+
|
||||
+ const kernel_ulong_t arg1 = fill | dirfd;
|
||||
+ const kernel_ulong_t arg2 = (uintptr_t) pathname;
|
||||
+ const kernel_ulong_t arg3 = fill | mode;
|
||||
+ const long rc = syscall(__NR_faccessat,
|
||||
+ arg1, arg2, arg3, bad, bad, bad);
|
||||
+ errstr = sprintrc(rc);
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
- static const char sample[] = "faccessat.sample";
|
||||
- const long int fd = (long int) 0xdeadbeefffffffffULL;
|
||||
+ SKIP_IF_PROC_IS_UNAVAILABLE;
|
||||
|
||||
- long rc = syscall(__NR_faccessat, fd, sample, F_OK);
|
||||
- printf("faccessat(%d, \"%s\", F_OK) = %ld %s (%m)\n",
|
||||
- (int) fd, sample, rc, errno2name());
|
||||
+ TAIL_ALLOC_OBJECT_CONST_PTR(const char, unterminated);
|
||||
+ char *unterminated_str;
|
||||
+ if (asprintf(&unterminated_str, "%p", unterminated) < 0)
|
||||
+ perror_msg_and_fail("asprintf");
|
||||
+ const void *const efault = unterminated + 1;
|
||||
+ char *efault_str;
|
||||
+ if (asprintf(&efault_str, "%p", efault) < 0)
|
||||
+ perror_msg_and_fail("asprintf");
|
||||
+
|
||||
+ typedef struct {
|
||||
+ char sym;
|
||||
+ char null;
|
||||
+ } sym_null;
|
||||
+
|
||||
+ TAIL_ALLOC_OBJECT_CONST_PTR(sym_null, dot);
|
||||
+ dot->sym = '.';
|
||||
+ dot->null = '\0';
|
||||
+ const char *const null = &dot->null;
|
||||
+
|
||||
+ TAIL_ALLOC_OBJECT_CONST_PTR(sym_null, slash);
|
||||
+ slash->sym = '/';
|
||||
+ slash->null = '\0';
|
||||
+
|
||||
+ static const char path[] = "/dev/full";
|
||||
+ const char *const fd_path = tail_memdup(path, sizeof(path));
|
||||
+ int fd = open(path, O_WRONLY);
|
||||
+ if (fd < 0)
|
||||
+ perror_msg_and_fail("open: %s", path);
|
||||
+ char *fd_str;
|
||||
+ if (asprintf(&fd_str, "%d%s", fd, FD_PATH) < 0)
|
||||
+ perror_msg_and_fail("asprintf");
|
||||
+ char *path_quoted;
|
||||
+ if (asprintf(&path_quoted, "\"%s\"", path) < 0)
|
||||
+ perror_msg_and_fail("asprintf");
|
||||
+
|
||||
+ struct {
|
||||
+ int val;
|
||||
+ const char *str;
|
||||
+ } dirfds[] = {
|
||||
+ { ARG_STR(-1) },
|
||||
+ { -100, "AT_FDCWD" },
|
||||
+ { fd, fd_str },
|
||||
+ }, modes[] = {
|
||||
+ { ARG_STR(F_OK) },
|
||||
+ { ARG_STR(R_OK) },
|
||||
+ { ARG_STR(W_OK) },
|
||||
+ { ARG_STR(X_OK) },
|
||||
+ { ARG_STR(R_OK|W_OK) },
|
||||
+ { ARG_STR(R_OK|X_OK) },
|
||||
+ { ARG_STR(W_OK|X_OK) },
|
||||
+ { ARG_STR(R_OK|W_OK|X_OK) },
|
||||
+ { 8, "0x8 /* ?_OK */" },
|
||||
+ { -1, "R_OK|W_OK|X_OK|0xfffffff8" },
|
||||
+ };
|
||||
+
|
||||
+ struct {
|
||||
+ const void *val;
|
||||
+ const char *str;
|
||||
+ } paths[] = {
|
||||
+ { 0, "NULL" },
|
||||
+ { efault, efault_str },
|
||||
+ { unterminated, unterminated_str },
|
||||
+ { null, "\"\"" },
|
||||
+ { &dot->sym, "\".\"" },
|
||||
+ { &slash->sym, "\"/\"" },
|
||||
+ { fd_path, path_quoted },
|
||||
+ };
|
||||
+
|
||||
+ for (unsigned int dirfd_i = 0;
|
||||
+ dirfd_i < ARRAY_SIZE(dirfds);
|
||||
+ ++dirfd_i) {
|
||||
+ for (unsigned int path_i = 0;
|
||||
+ path_i < ARRAY_SIZE(paths);
|
||||
+ ++path_i) {
|
||||
+ for (unsigned int mode_i = 0;
|
||||
+ mode_i < ARRAY_SIZE(modes);
|
||||
+ ++mode_i) {
|
||||
+ k_faccessat(dirfds[dirfd_i].val,
|
||||
+ paths[path_i].val,
|
||||
+ modes[mode_i].val);
|
||||
+# ifdef PATH_TRACING
|
||||
+ if (dirfds[dirfd_i].val == fd ||
|
||||
+ paths[path_i].val == fd_path)
|
||||
+# endif
|
||||
+ printf("faccessat(%s, %s, %s) = %s\n",
|
||||
+ dirfds[dirfd_i].str,
|
||||
+ paths[path_i].str,
|
||||
+ modes[mode_i].str,
|
||||
+ errstr);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
puts("+++ exited with 0 +++");
|
||||
return 0;
|
||||
Index: strace-5.7/tests/faccessat.test
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ strace-5.7/tests/faccessat.test 2021-08-24 19:46:08.277554353 +0200
|
||||
@@ -0,0 +1,19 @@
|
||||
+#!/bin/sh
|
||||
+#
|
||||
+# Check decoding of faccessat syscall.
|
||||
+#
|
||||
+# Copyright (c) 2020 Dmitry V. Levin <ldv@altlinux.org>
|
||||
+# All rights reserved.
|
||||
+#
|
||||
+# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+
|
||||
+. "${srcdir=.}/init.sh"
|
||||
+
|
||||
+check_prog sed
|
||||
+
|
||||
+run_prog > /dev/null
|
||||
+run_strace -a23 --trace=faccessat "$@" $args > "$EXP"
|
||||
+
|
||||
+# Filter out faccessat() calls made by ld.so and libc.
|
||||
+sed -n '/^faccessat(-1, NULL,/,$p' < "$LOG" > "$OUT"
|
||||
+match_diff "$OUT" "$EXP"
|
||||
Index: strace-5.7/tests/gen_tests.in
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests/gen_tests.in 2021-08-24 19:37:43.192829355 +0200
|
||||
+++ strace-5.7/tests/gen_tests.in 2021-08-24 19:46:08.278554345 +0200
|
||||
@@ -73,7 +73,9 @@
|
||||
erestartsys -a34 -e signal=none -e trace=recvfrom
|
||||
execveat
|
||||
execveat-v -v -e trace=execveat
|
||||
-faccessat -P $NAME.sample
|
||||
+faccessat-P -a23 --trace=faccessat -P /dev/full
|
||||
+faccessat-y +faccessat.test -a24 -y
|
||||
+faccessat-yy +faccessat.test -a24 -yy
|
||||
fadvise64_64 +fadvise64.test
|
||||
fallocate -a18
|
||||
fanotify_init
|
||||
Index: strace-5.7/tests/pure_executables.list
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests/pure_executables.list 2021-08-24 19:37:43.192829355 +0200
|
||||
+++ strace-5.7/tests/pure_executables.list 2021-08-24 19:46:08.279554336 +0200
|
||||
@@ -61,6 +61,9 @@
|
||||
execve
|
||||
execveat
|
||||
faccessat
|
||||
+faccessat-P
|
||||
+faccessat-y
|
||||
+faccessat-yy
|
||||
fadvise64
|
||||
fadvise64_64
|
||||
fallocate
|
||||
Index: strace-5.7/tests-m32/Makefile.am
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests-m32/Makefile.am 2021-08-24 19:42:16.045519949 +0200
|
||||
+++ strace-5.7/tests-m32/Makefile.am 2021-08-24 19:46:08.279554336 +0200
|
||||
@@ -346,6 +346,7 @@
|
||||
execve-v.test \
|
||||
execve.test \
|
||||
fadvise64.test \
|
||||
+ faccessat.test \
|
||||
futex.test \
|
||||
getuid.test \
|
||||
int_0x80.test \
|
||||
Index: strace-5.7/tests-m32/faccessat-P.c
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ strace-5.7/tests-m32/faccessat-P.c 2021-08-24 19:46:08.279554336 +0200
|
||||
@@ -0,0 +1,4 @@
|
||||
+#define PATH_TRACING
|
||||
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
|
||||
+
|
||||
+#include "faccessat.c"
|
||||
Index: strace-5.7/tests-m32/faccessat-y.c
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ strace-5.7/tests-m32/faccessat-y.c 2021-08-24 19:46:08.280554328 +0200
|
||||
@@ -0,0 +1,4 @@
|
||||
+#define FD_PATH "</dev/full>"
|
||||
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
|
||||
+
|
||||
+#include "faccessat.c"
|
||||
Index: strace-5.7/tests-m32/faccessat-yy.c
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ strace-5.7/tests-m32/faccessat-yy.c 2021-08-24 19:46:08.280554328 +0200
|
||||
@@ -0,0 +1,4 @@
|
||||
+#define FD_PATH "</dev/full<char 1:7>>"
|
||||
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
|
||||
+
|
||||
+#include "faccessat.c"
|
||||
Index: strace-5.7/tests-m32/faccessat.c
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests-m32/faccessat.c 2019-09-25 03:02:03.000000000 +0200
|
||||
+++ strace-5.7/tests-m32/faccessat.c 2021-08-24 19:46:08.281554319 +0200
|
||||
@@ -1,4 +1,6 @@
|
||||
/*
|
||||
+ * Check decoding of faccessat syscall.
|
||||
+ *
|
||||
* Copyright (c) 2016-2019 The strace developers.
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -10,18 +12,133 @@
|
||||
|
||||
#ifdef __NR_faccessat
|
||||
|
||||
+# include <fcntl.h>
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
|
||||
+# ifndef FD_PATH
|
||||
+# define FD_PATH ""
|
||||
+# endif
|
||||
+# ifndef SKIP_IF_PROC_IS_UNAVAILABLE
|
||||
+# define SKIP_IF_PROC_IS_UNAVAILABLE
|
||||
+# endif
|
||||
+
|
||||
+static const char *errstr;
|
||||
+
|
||||
+static long
|
||||
+k_faccessat(const unsigned int dirfd,
|
||||
+ const void *const pathname,
|
||||
+ const unsigned int mode)
|
||||
+{
|
||||
+ const kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
|
||||
+ const kernel_ulong_t bad = (kernel_ulong_t) 0xbadc0dedbadc0dedULL;
|
||||
+
|
||||
+ const kernel_ulong_t arg1 = fill | dirfd;
|
||||
+ const kernel_ulong_t arg2 = (uintptr_t) pathname;
|
||||
+ const kernel_ulong_t arg3 = fill | mode;
|
||||
+ const long rc = syscall(__NR_faccessat,
|
||||
+ arg1, arg2, arg3, bad, bad, bad);
|
||||
+ errstr = sprintrc(rc);
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
- static const char sample[] = "faccessat.sample";
|
||||
- const long int fd = (long int) 0xdeadbeefffffffffULL;
|
||||
+ SKIP_IF_PROC_IS_UNAVAILABLE;
|
||||
|
||||
- long rc = syscall(__NR_faccessat, fd, sample, F_OK);
|
||||
- printf("faccessat(%d, \"%s\", F_OK) = %ld %s (%m)\n",
|
||||
- (int) fd, sample, rc, errno2name());
|
||||
+ TAIL_ALLOC_OBJECT_CONST_PTR(const char, unterminated);
|
||||
+ char *unterminated_str;
|
||||
+ if (asprintf(&unterminated_str, "%p", unterminated) < 0)
|
||||
+ perror_msg_and_fail("asprintf");
|
||||
+ const void *const efault = unterminated + 1;
|
||||
+ char *efault_str;
|
||||
+ if (asprintf(&efault_str, "%p", efault) < 0)
|
||||
+ perror_msg_and_fail("asprintf");
|
||||
+
|
||||
+ typedef struct {
|
||||
+ char sym;
|
||||
+ char null;
|
||||
+ } sym_null;
|
||||
+
|
||||
+ TAIL_ALLOC_OBJECT_CONST_PTR(sym_null, dot);
|
||||
+ dot->sym = '.';
|
||||
+ dot->null = '\0';
|
||||
+ const char *const null = &dot->null;
|
||||
+
|
||||
+ TAIL_ALLOC_OBJECT_CONST_PTR(sym_null, slash);
|
||||
+ slash->sym = '/';
|
||||
+ slash->null = '\0';
|
||||
+
|
||||
+ static const char path[] = "/dev/full";
|
||||
+ const char *const fd_path = tail_memdup(path, sizeof(path));
|
||||
+ int fd = open(path, O_WRONLY);
|
||||
+ if (fd < 0)
|
||||
+ perror_msg_and_fail("open: %s", path);
|
||||
+ char *fd_str;
|
||||
+ if (asprintf(&fd_str, "%d%s", fd, FD_PATH) < 0)
|
||||
+ perror_msg_and_fail("asprintf");
|
||||
+ char *path_quoted;
|
||||
+ if (asprintf(&path_quoted, "\"%s\"", path) < 0)
|
||||
+ perror_msg_and_fail("asprintf");
|
||||
+
|
||||
+ struct {
|
||||
+ int val;
|
||||
+ const char *str;
|
||||
+ } dirfds[] = {
|
||||
+ { ARG_STR(-1) },
|
||||
+ { -100, "AT_FDCWD" },
|
||||
+ { fd, fd_str },
|
||||
+ }, modes[] = {
|
||||
+ { ARG_STR(F_OK) },
|
||||
+ { ARG_STR(R_OK) },
|
||||
+ { ARG_STR(W_OK) },
|
||||
+ { ARG_STR(X_OK) },
|
||||
+ { ARG_STR(R_OK|W_OK) },
|
||||
+ { ARG_STR(R_OK|X_OK) },
|
||||
+ { ARG_STR(W_OK|X_OK) },
|
||||
+ { ARG_STR(R_OK|W_OK|X_OK) },
|
||||
+ { 8, "0x8 /* ?_OK */" },
|
||||
+ { -1, "R_OK|W_OK|X_OK|0xfffffff8" },
|
||||
+ };
|
||||
+
|
||||
+ struct {
|
||||
+ const void *val;
|
||||
+ const char *str;
|
||||
+ } paths[] = {
|
||||
+ { 0, "NULL" },
|
||||
+ { efault, efault_str },
|
||||
+ { unterminated, unterminated_str },
|
||||
+ { null, "\"\"" },
|
||||
+ { &dot->sym, "\".\"" },
|
||||
+ { &slash->sym, "\"/\"" },
|
||||
+ { fd_path, path_quoted },
|
||||
+ };
|
||||
+
|
||||
+ for (unsigned int dirfd_i = 0;
|
||||
+ dirfd_i < ARRAY_SIZE(dirfds);
|
||||
+ ++dirfd_i) {
|
||||
+ for (unsigned int path_i = 0;
|
||||
+ path_i < ARRAY_SIZE(paths);
|
||||
+ ++path_i) {
|
||||
+ for (unsigned int mode_i = 0;
|
||||
+ mode_i < ARRAY_SIZE(modes);
|
||||
+ ++mode_i) {
|
||||
+ k_faccessat(dirfds[dirfd_i].val,
|
||||
+ paths[path_i].val,
|
||||
+ modes[mode_i].val);
|
||||
+# ifdef PATH_TRACING
|
||||
+ if (dirfds[dirfd_i].val == fd ||
|
||||
+ paths[path_i].val == fd_path)
|
||||
+# endif
|
||||
+ printf("faccessat(%s, %s, %s) = %s\n",
|
||||
+ dirfds[dirfd_i].str,
|
||||
+ paths[path_i].str,
|
||||
+ modes[mode_i].str,
|
||||
+ errstr);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
puts("+++ exited with 0 +++");
|
||||
return 0;
|
||||
Index: strace-5.7/tests-m32/faccessat.test
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ strace-5.7/tests-m32/faccessat.test 2021-08-24 19:46:08.281554319 +0200
|
||||
@@ -0,0 +1,19 @@
|
||||
+#!/bin/sh
|
||||
+#
|
||||
+# Check decoding of faccessat syscall.
|
||||
+#
|
||||
+# Copyright (c) 2020 Dmitry V. Levin <ldv@altlinux.org>
|
||||
+# All rights reserved.
|
||||
+#
|
||||
+# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+
|
||||
+. "${srcdir=.}/init.sh"
|
||||
+
|
||||
+check_prog sed
|
||||
+
|
||||
+run_prog > /dev/null
|
||||
+run_strace -a23 --trace=faccessat "$@" $args > "$EXP"
|
||||
+
|
||||
+# Filter out faccessat() calls made by ld.so and libc.
|
||||
+sed -n '/^faccessat(-1, NULL,/,$p' < "$LOG" > "$OUT"
|
||||
+match_diff "$OUT" "$EXP"
|
||||
Index: strace-5.7/tests-m32/gen_tests.in
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests-m32/gen_tests.in 2021-08-24 19:37:43.193829347 +0200
|
||||
+++ strace-5.7/tests-m32/gen_tests.in 2021-08-24 19:46:08.282554311 +0200
|
||||
@@ -73,7 +73,9 @@
|
||||
erestartsys -a34 -e signal=none -e trace=recvfrom
|
||||
execveat
|
||||
execveat-v -v -e trace=execveat
|
||||
-faccessat -P $NAME.sample
|
||||
+faccessat-P -a23 --trace=faccessat -P /dev/full
|
||||
+faccessat-y +faccessat.test -a24 -y
|
||||
+faccessat-yy +faccessat.test -a24 -yy
|
||||
fadvise64_64 +fadvise64.test
|
||||
fallocate -a18
|
||||
fanotify_init
|
||||
Index: strace-5.7/tests-m32/pure_executables.list
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests-m32/pure_executables.list 2021-08-24 19:37:43.193829347 +0200
|
||||
+++ strace-5.7/tests-m32/pure_executables.list 2021-08-24 19:46:08.283554302 +0200
|
||||
@@ -61,6 +61,9 @@
|
||||
execve
|
||||
execveat
|
||||
faccessat
|
||||
+faccessat-P
|
||||
+faccessat-y
|
||||
+faccessat-yy
|
||||
fadvise64
|
||||
fadvise64_64
|
||||
fallocate
|
||||
Index: strace-5.7/tests-mx32/Makefile.am
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests-mx32/Makefile.am 2021-08-24 19:42:16.048519924 +0200
|
||||
+++ strace-5.7/tests-mx32/Makefile.am 2021-08-24 19:46:08.283554302 +0200
|
||||
@@ -346,6 +346,7 @@
|
||||
execve-v.test \
|
||||
execve.test \
|
||||
fadvise64.test \
|
||||
+ faccessat.test \
|
||||
futex.test \
|
||||
getuid.test \
|
||||
int_0x80.test \
|
||||
Index: strace-5.7/tests-mx32/faccessat-P.c
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ strace-5.7/tests-mx32/faccessat-P.c 2021-08-24 19:46:08.283554302 +0200
|
||||
@@ -0,0 +1,4 @@
|
||||
+#define PATH_TRACING
|
||||
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
|
||||
+
|
||||
+#include "faccessat.c"
|
||||
Index: strace-5.7/tests-mx32/faccessat-y.c
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ strace-5.7/tests-mx32/faccessat-y.c 2021-08-24 19:46:08.284554294 +0200
|
||||
@@ -0,0 +1,4 @@
|
||||
+#define FD_PATH "</dev/full>"
|
||||
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
|
||||
+
|
||||
+#include "faccessat.c"
|
||||
Index: strace-5.7/tests-mx32/faccessat-yy.c
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ strace-5.7/tests-mx32/faccessat-yy.c 2021-08-24 19:46:08.284554294 +0200
|
||||
@@ -0,0 +1,4 @@
|
||||
+#define FD_PATH "</dev/full<char 1:7>>"
|
||||
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
|
||||
+
|
||||
+#include "faccessat.c"
|
||||
Index: strace-5.7/tests-mx32/faccessat.c
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests-mx32/faccessat.c 2019-09-25 03:02:03.000000000 +0200
|
||||
+++ strace-5.7/tests-mx32/faccessat.c 2021-08-24 19:46:08.285554285 +0200
|
||||
@@ -1,4 +1,6 @@
|
||||
/*
|
||||
+ * Check decoding of faccessat syscall.
|
||||
+ *
|
||||
* Copyright (c) 2016-2019 The strace developers.
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -10,18 +12,133 @@
|
||||
|
||||
#ifdef __NR_faccessat
|
||||
|
||||
+# include <fcntl.h>
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
|
||||
+# ifndef FD_PATH
|
||||
+# define FD_PATH ""
|
||||
+# endif
|
||||
+# ifndef SKIP_IF_PROC_IS_UNAVAILABLE
|
||||
+# define SKIP_IF_PROC_IS_UNAVAILABLE
|
||||
+# endif
|
||||
+
|
||||
+static const char *errstr;
|
||||
+
|
||||
+static long
|
||||
+k_faccessat(const unsigned int dirfd,
|
||||
+ const void *const pathname,
|
||||
+ const unsigned int mode)
|
||||
+{
|
||||
+ const kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
|
||||
+ const kernel_ulong_t bad = (kernel_ulong_t) 0xbadc0dedbadc0dedULL;
|
||||
+
|
||||
+ const kernel_ulong_t arg1 = fill | dirfd;
|
||||
+ const kernel_ulong_t arg2 = (uintptr_t) pathname;
|
||||
+ const kernel_ulong_t arg3 = fill | mode;
|
||||
+ const long rc = syscall(__NR_faccessat,
|
||||
+ arg1, arg2, arg3, bad, bad, bad);
|
||||
+ errstr = sprintrc(rc);
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
- static const char sample[] = "faccessat.sample";
|
||||
- const long int fd = (long int) 0xdeadbeefffffffffULL;
|
||||
+ SKIP_IF_PROC_IS_UNAVAILABLE;
|
||||
|
||||
- long rc = syscall(__NR_faccessat, fd, sample, F_OK);
|
||||
- printf("faccessat(%d, \"%s\", F_OK) = %ld %s (%m)\n",
|
||||
- (int) fd, sample, rc, errno2name());
|
||||
+ TAIL_ALLOC_OBJECT_CONST_PTR(const char, unterminated);
|
||||
+ char *unterminated_str;
|
||||
+ if (asprintf(&unterminated_str, "%p", unterminated) < 0)
|
||||
+ perror_msg_and_fail("asprintf");
|
||||
+ const void *const efault = unterminated + 1;
|
||||
+ char *efault_str;
|
||||
+ if (asprintf(&efault_str, "%p", efault) < 0)
|
||||
+ perror_msg_and_fail("asprintf");
|
||||
+
|
||||
+ typedef struct {
|
||||
+ char sym;
|
||||
+ char null;
|
||||
+ } sym_null;
|
||||
+
|
||||
+ TAIL_ALLOC_OBJECT_CONST_PTR(sym_null, dot);
|
||||
+ dot->sym = '.';
|
||||
+ dot->null = '\0';
|
||||
+ const char *const null = &dot->null;
|
||||
+
|
||||
+ TAIL_ALLOC_OBJECT_CONST_PTR(sym_null, slash);
|
||||
+ slash->sym = '/';
|
||||
+ slash->null = '\0';
|
||||
+
|
||||
+ static const char path[] = "/dev/full";
|
||||
+ const char *const fd_path = tail_memdup(path, sizeof(path));
|
||||
+ int fd = open(path, O_WRONLY);
|
||||
+ if (fd < 0)
|
||||
+ perror_msg_and_fail("open: %s", path);
|
||||
+ char *fd_str;
|
||||
+ if (asprintf(&fd_str, "%d%s", fd, FD_PATH) < 0)
|
||||
+ perror_msg_and_fail("asprintf");
|
||||
+ char *path_quoted;
|
||||
+ if (asprintf(&path_quoted, "\"%s\"", path) < 0)
|
||||
+ perror_msg_and_fail("asprintf");
|
||||
+
|
||||
+ struct {
|
||||
+ int val;
|
||||
+ const char *str;
|
||||
+ } dirfds[] = {
|
||||
+ { ARG_STR(-1) },
|
||||
+ { -100, "AT_FDCWD" },
|
||||
+ { fd, fd_str },
|
||||
+ }, modes[] = {
|
||||
+ { ARG_STR(F_OK) },
|
||||
+ { ARG_STR(R_OK) },
|
||||
+ { ARG_STR(W_OK) },
|
||||
+ { ARG_STR(X_OK) },
|
||||
+ { ARG_STR(R_OK|W_OK) },
|
||||
+ { ARG_STR(R_OK|X_OK) },
|
||||
+ { ARG_STR(W_OK|X_OK) },
|
||||
+ { ARG_STR(R_OK|W_OK|X_OK) },
|
||||
+ { 8, "0x8 /* ?_OK */" },
|
||||
+ { -1, "R_OK|W_OK|X_OK|0xfffffff8" },
|
||||
+ };
|
||||
+
|
||||
+ struct {
|
||||
+ const void *val;
|
||||
+ const char *str;
|
||||
+ } paths[] = {
|
||||
+ { 0, "NULL" },
|
||||
+ { efault, efault_str },
|
||||
+ { unterminated, unterminated_str },
|
||||
+ { null, "\"\"" },
|
||||
+ { &dot->sym, "\".\"" },
|
||||
+ { &slash->sym, "\"/\"" },
|
||||
+ { fd_path, path_quoted },
|
||||
+ };
|
||||
+
|
||||
+ for (unsigned int dirfd_i = 0;
|
||||
+ dirfd_i < ARRAY_SIZE(dirfds);
|
||||
+ ++dirfd_i) {
|
||||
+ for (unsigned int path_i = 0;
|
||||
+ path_i < ARRAY_SIZE(paths);
|
||||
+ ++path_i) {
|
||||
+ for (unsigned int mode_i = 0;
|
||||
+ mode_i < ARRAY_SIZE(modes);
|
||||
+ ++mode_i) {
|
||||
+ k_faccessat(dirfds[dirfd_i].val,
|
||||
+ paths[path_i].val,
|
||||
+ modes[mode_i].val);
|
||||
+# ifdef PATH_TRACING
|
||||
+ if (dirfds[dirfd_i].val == fd ||
|
||||
+ paths[path_i].val == fd_path)
|
||||
+# endif
|
||||
+ printf("faccessat(%s, %s, %s) = %s\n",
|
||||
+ dirfds[dirfd_i].str,
|
||||
+ paths[path_i].str,
|
||||
+ modes[mode_i].str,
|
||||
+ errstr);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
puts("+++ exited with 0 +++");
|
||||
return 0;
|
||||
Index: strace-5.7/tests-mx32/faccessat.test
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ strace-5.7/tests-mx32/faccessat.test 2021-08-24 19:46:08.285554285 +0200
|
||||
@@ -0,0 +1,19 @@
|
||||
+#!/bin/sh
|
||||
+#
|
||||
+# Check decoding of faccessat syscall.
|
||||
+#
|
||||
+# Copyright (c) 2020 Dmitry V. Levin <ldv@altlinux.org>
|
||||
+# All rights reserved.
|
||||
+#
|
||||
+# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+
|
||||
+. "${srcdir=.}/init.sh"
|
||||
+
|
||||
+check_prog sed
|
||||
+
|
||||
+run_prog > /dev/null
|
||||
+run_strace -a23 --trace=faccessat "$@" $args > "$EXP"
|
||||
+
|
||||
+# Filter out faccessat() calls made by ld.so and libc.
|
||||
+sed -n '/^faccessat(-1, NULL,/,$p' < "$LOG" > "$OUT"
|
||||
+match_diff "$OUT" "$EXP"
|
||||
Index: strace-5.7/tests-mx32/gen_tests.in
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests-mx32/gen_tests.in 2021-08-24 19:37:43.194829339 +0200
|
||||
+++ strace-5.7/tests-mx32/gen_tests.in 2021-08-24 19:46:08.286554277 +0200
|
||||
@@ -73,7 +73,9 @@
|
||||
erestartsys -a34 -e signal=none -e trace=recvfrom
|
||||
execveat
|
||||
execveat-v -v -e trace=execveat
|
||||
-faccessat -P $NAME.sample
|
||||
+faccessat-P -a23 --trace=faccessat -P /dev/full
|
||||
+faccessat-y +faccessat.test -a24 -y
|
||||
+faccessat-yy +faccessat.test -a24 -yy
|
||||
fadvise64_64 +fadvise64.test
|
||||
fallocate -a18
|
||||
fanotify_init
|
||||
Index: strace-5.7/tests-mx32/pure_executables.list
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests-mx32/pure_executables.list 2021-08-24 19:37:43.195829330 +0200
|
||||
+++ strace-5.7/tests-mx32/pure_executables.list 2021-08-24 19:46:08.286554277 +0200
|
||||
@@ -61,6 +61,9 @@
|
||||
execve
|
||||
execveat
|
||||
faccessat
|
||||
+faccessat-P
|
||||
+faccessat-y
|
||||
+faccessat-yy
|
||||
fadvise64
|
||||
fadvise64_64
|
||||
fallocate
|
||||
Index: strace-5.7/tests/Makefile.in
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests/Makefile.in 2021-08-24 19:42:54.720192609 +0200
|
||||
+++ strace-5.7/tests/Makefile.in 2021-08-24 19:46:08.292554226 +0200
|
||||
@@ -6523,6 +6523,7 @@
|
||||
execve-v.test \
|
||||
execve.test \
|
||||
fadvise64.test \
|
||||
+ faccessat.test \
|
||||
futex.test \
|
||||
getuid.test \
|
||||
int_0x80.test \
|
||||
Index: strace-5.7/tests-m32/Makefile.in
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests-m32/Makefile.in 2021-08-24 19:43:13.669032228 +0200
|
||||
+++ strace-5.7/tests-m32/Makefile.in 2021-08-24 19:46:08.296554192 +0200
|
||||
@@ -6523,6 +6523,7 @@
|
||||
execve-v.test \
|
||||
execve.test \
|
||||
fadvise64.test \
|
||||
+ faccessat.test \
|
||||
futex.test \
|
||||
getuid.test \
|
||||
int_0x80.test \
|
||||
Index: strace-5.7/tests-mx32/Makefile.in
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests-mx32/Makefile.in 2021-08-24 19:43:32.469873099 +0200
|
||||
+++ strace-5.7/tests-mx32/Makefile.in 2021-08-24 19:46:08.299554167 +0200
|
||||
@@ -6523,6 +6523,7 @@
|
||||
execve-v.test \
|
||||
execve.test \
|
||||
fadvise64.test \
|
||||
+ faccessat.test \
|
||||
futex.test \
|
||||
getuid.test \
|
||||
int_0x80.test \
|
65
SOURCES/0145-xmalloc-introduce-xasprintf.patch
Normal file
65
SOURCES/0145-xmalloc-introduce-xasprintf.patch
Normal file
@ -0,0 +1,65 @@
|
||||
From f2b8769e4a9aa99cd5e0aef41a0408c34de3cc8e Mon Sep 17 00:00:00 2001
|
||||
From: "Dmitry V. Levin" <ldv@strace.io>
|
||||
Date: Mon, 15 Mar 2021 08:00:00 +0000
|
||||
Subject: [PATCH 145/149] xmalloc: introduce xasprintf
|
||||
|
||||
xasprintf is a trivial wrapper around vasprintf,
|
||||
the primary purpose of adding it is to simplify tests.
|
||||
|
||||
* xmalloc.h (xasprintf): New function declaration.
|
||||
* xmalloc.c: Include <stdarg.h> and <stdio.h>
|
||||
(xasprintf): New function.
|
||||
---
|
||||
xmalloc.c | 16 ++++++++++++++++
|
||||
xmalloc.h | 6 ++++++
|
||||
2 files changed, 22 insertions(+)
|
||||
|
||||
diff --git a/xmalloc.c b/xmalloc.c
|
||||
index 8688f91..75019e9 100644
|
||||
--- a/xmalloc.c
|
||||
+++ b/xmalloc.c
|
||||
@@ -10,6 +10,8 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
+#include <stdarg.h>
|
||||
+#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -146,3 +148,17 @@ xstrndup(const char *str, size_t n)
|
||||
|
||||
return p;
|
||||
}
|
||||
+
|
||||
+char *
|
||||
+xasprintf(const char *fmt, ...)
|
||||
+{
|
||||
+ va_list ap;
|
||||
+ va_start(ap, fmt);
|
||||
+
|
||||
+ char *res;
|
||||
+ if (vasprintf(&res, fmt, ap) < 0)
|
||||
+ die_out_of_memory();
|
||||
+
|
||||
+ va_end(ap);
|
||||
+ return res;
|
||||
+}
|
||||
diff --git a/xmalloc.h b/xmalloc.h
|
||||
index 4bf1e2c..1305a1e 100644
|
||||
--- a/xmalloc.h
|
||||
+++ b/xmalloc.h
|
||||
@@ -77,4 +77,10 @@ void *xgrowarray(void *ptr, size_t *nmemb, size_t memb_size);
|
||||
char *xstrdup(const char *str) ATTRIBUTE_MALLOC;
|
||||
char *xstrndup(const char *str, size_t n) ATTRIBUTE_MALLOC;
|
||||
|
||||
+/**
|
||||
+ * Analogous to asprintf, die in case of an error.
|
||||
+ */
|
||||
+char *xasprintf(const char *fmt, ...)
|
||||
+ ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_MALLOC;
|
||||
+
|
||||
#endif /* !STRACE_XMALLOC_H */
|
||||
--
|
||||
2.1.4
|
||||
|
891
SOURCES/0146-tests-use-xasprintf-instead-of-asprintf.patch
Normal file
891
SOURCES/0146-tests-use-xasprintf-instead-of-asprintf.patch
Normal file
@ -0,0 +1,891 @@
|
||||
From bcd0f3ef964aead4b9e95c10f4c5c75f58ba102c Mon Sep 17 00:00:00 2001
|
||||
From: "Dmitry V. Levin" <ldv@strace.io>
|
||||
Date: Mon, 15 Mar 2021 08:00:00 +0000
|
||||
Subject: [PATCH 146/149] tests: use xasprintf instead of asprintf
|
||||
|
||||
* tests/clone-flags.c: Include "xmalloc.h", replace all asprintf
|
||||
invocations followed by perror_msg_and_fail with xasprintf.
|
||||
* tests/epoll_pwait2.c: Likewise.
|
||||
* tests/faccessat.c: Likewise.
|
||||
* tests/faccessat2.c: Likewise.
|
||||
* tests/ioctl_kvm_run_common.c: Likewise.
|
||||
* tests/keyctl.c: Likewise.
|
||||
* tests/lock_file.c: Likewise.
|
||||
* tests/mq.c: Likewise.
|
||||
* tests/mq_sendrecv.c: Likewise.
|
||||
* tests/netlink_protocol.c: Likewise.
|
||||
* tests/old_mmap.c: Likewise.
|
||||
* tests/tracer_ppid_pgid_sid.c: Likewise.
|
||||
|
||||
Conflicts:
|
||||
tests/epoll_pwait2.c
|
||||
tests/faccessat2.c
|
||||
tests/mq_sendrecv.c
|
||||
---
|
||||
tests/clone-flags.c | 5 ++---
|
||||
tests/faccessat.c | 17 +++++------------
|
||||
tests/ioctl_kvm_run_common.c | 6 ++----
|
||||
tests/keyctl.c | 29 +++++++++++++----------------
|
||||
tests/lock_file.c | 5 ++---
|
||||
tests/mq.c | 5 ++---
|
||||
tests/mq_sendrecv.c | 4 ++--
|
||||
tests/netlink_protocol.c | 5 ++---
|
||||
tests/old_mmap.c | 5 ++---
|
||||
tests/tracer_ppid_pgid_sid.c | 6 ++----
|
||||
10 files changed, 34 insertions(+), 53 deletions(-)
|
||||
|
||||
diff --git a/tests/clone-flags.c b/tests/clone-flags.c
|
||||
index 04bb2c7..aa7d48c 100644
|
||||
--- a/tests/clone-flags.c
|
||||
+++ b/tests/clone-flags.c
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "tests.h"
|
||||
+#include "xmalloc.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
@@ -134,9 +135,7 @@ main(void)
|
||||
*ptid = 0;
|
||||
pid = do_clone(child, child_stack, child_stack_size,
|
||||
CLONE_PIDFD|SIGCHLD, 0, ptid);
|
||||
- char *fname = 0;
|
||||
- if (asprintf(&fname, "/proc/self/fd/%d", *ptid) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *fname = xasprintf("/proc/self/fd/%d", *ptid);
|
||||
int rc = readlink(fname, buf, sizeof(buf) - 1);
|
||||
if ((unsigned int) rc >= sizeof(buf))
|
||||
perror_msg_and_fail("readlink");
|
||||
diff --git a/tests/faccessat.c b/tests/faccessat.c
|
||||
index c42aa2d..8cda6f3 100644
|
||||
--- a/tests/faccessat.c
|
||||
+++ b/tests/faccessat.c
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#ifdef __NR_faccessat
|
||||
|
||||
+# include "xmalloc.h"
|
||||
# include <fcntl.h>
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
@@ -48,13 +49,9 @@ main(void)
|
||||
SKIP_IF_PROC_IS_UNAVAILABLE;
|
||||
|
||||
TAIL_ALLOC_OBJECT_CONST_PTR(const char, unterminated);
|
||||
- char *unterminated_str;
|
||||
- if (asprintf(&unterminated_str, "%p", unterminated) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *unterminated_str = xasprintf("%p", unterminated);
|
||||
const void *const efault = unterminated + 1;
|
||||
- char *efault_str;
|
||||
- if (asprintf(&efault_str, "%p", efault) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *efault_str = xasprintf("%p", efault);
|
||||
|
||||
typedef struct {
|
||||
char sym;
|
||||
@@ -75,12 +72,8 @@ main(void)
|
||||
int fd = open(path, O_WRONLY);
|
||||
if (fd < 0)
|
||||
perror_msg_and_fail("open: %s", path);
|
||||
- char *fd_str;
|
||||
- if (asprintf(&fd_str, "%d%s", fd, FD_PATH) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
- char *path_quoted;
|
||||
- if (asprintf(&path_quoted, "\"%s\"", path) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *fd_str = xasprintf("%d%s", fd, FD_PATH);
|
||||
+ char *path_quoted = xasprintf("\"%s\"", path);
|
||||
|
||||
struct {
|
||||
int val;
|
||||
diff --git a/tests/ioctl_kvm_run_common.c b/tests/ioctl_kvm_run_common.c
|
||||
index 9107c30..be1190e 100644
|
||||
--- a/tests/ioctl_kvm_run_common.c
|
||||
+++ b/tests/ioctl_kvm_run_common.c
|
||||
@@ -48,6 +48,7 @@
|
||||
# define KVM_MAX_CPUID_ENTRIES 80
|
||||
# endif
|
||||
|
||||
+# include "xmalloc.h"
|
||||
# include "xlat.h"
|
||||
# include "xlat/kvm_cpuid_flags.h"
|
||||
|
||||
@@ -254,12 +255,9 @@ static int
|
||||
vcpu_dev_should_have_cpuid(int fd)
|
||||
{
|
||||
int r = 0;
|
||||
- char *filename = NULL;
|
||||
+ char *filename = xasprintf("/proc/%d/fd/%d", getpid(), fd);
|
||||
char buf[sizeof(vcpu_dev)];
|
||||
|
||||
- if (asprintf(&filename, "/proc/%d/fd/%d", getpid(), fd) < 0)
|
||||
- error_msg_and_fail("asprintf");
|
||||
-
|
||||
if (readlink(filename, buf, sizeof(buf)) == sizeof(buf) - 1
|
||||
&& (memcmp(buf, vcpu_dev, sizeof(buf) - 1) == 0))
|
||||
r = 1;
|
||||
diff --git a/tests/keyctl.c b/tests/keyctl.c
|
||||
index 6dc30fb..96ac197 100644
|
||||
--- a/tests/keyctl.c
|
||||
+++ b/tests/keyctl.c
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "tests.h"
|
||||
|
||||
#include "scno.h"
|
||||
+#include "xmalloc.h"
|
||||
|
||||
#ifdef __NR_keyctl
|
||||
|
||||
@@ -445,7 +446,6 @@ main(void)
|
||||
struct iovec *key_iov = tail_alloc(sizeof(*key_iov) * IOV_SIZE);
|
||||
char *bogus_buf1 = tail_alloc(9);
|
||||
char *bogus_buf2 = tail_alloc(256);
|
||||
- char *key_iov_str1;
|
||||
char *key_iov_str2 = tail_alloc(4096);
|
||||
const char *errstr;
|
||||
ssize_t ret;
|
||||
@@ -472,21 +472,18 @@ main(void)
|
||||
0x100000001ULL * i);
|
||||
}
|
||||
|
||||
- ret = asprintf(&key_iov_str1, "[{iov_base=%p, iov_len=%zu}, "
|
||||
- "{iov_base=%p, iov_len=%zu}, "
|
||||
- "{iov_base=%p, iov_len=%zu}, "
|
||||
- "{iov_base=%p, iov_len=%zu}]",
|
||||
- key_iov[IOV_SIZE - 4].iov_base,
|
||||
- key_iov[IOV_SIZE - 4].iov_len,
|
||||
- key_iov[IOV_SIZE - 3].iov_base,
|
||||
- key_iov[IOV_SIZE - 3].iov_len,
|
||||
- key_iov[IOV_SIZE - 2].iov_base,
|
||||
- key_iov[IOV_SIZE - 2].iov_len,
|
||||
- key_iov[IOV_SIZE - 1].iov_base,
|
||||
- key_iov[IOV_SIZE - 1].iov_len);
|
||||
-
|
||||
- if (ret < 0)
|
||||
- error_msg_and_fail("asprintf");
|
||||
+ char *key_iov_str1 = xasprintf("[{iov_base=%p, iov_len=%zu}, "
|
||||
+ "{iov_base=%p, iov_len=%zu}, "
|
||||
+ "{iov_base=%p, iov_len=%zu}, "
|
||||
+ "{iov_base=%p, iov_len=%zu}]",
|
||||
+ key_iov[IOV_SIZE - 4].iov_base,
|
||||
+ key_iov[IOV_SIZE - 4].iov_len,
|
||||
+ key_iov[IOV_SIZE - 3].iov_base,
|
||||
+ key_iov[IOV_SIZE - 3].iov_len,
|
||||
+ key_iov[IOV_SIZE - 2].iov_base,
|
||||
+ key_iov[IOV_SIZE - 2].iov_len,
|
||||
+ key_iov[IOV_SIZE - 1].iov_base,
|
||||
+ key_iov[IOV_SIZE - 1].iov_len);
|
||||
|
||||
ret = snprintf(key_iov_str2, IOV_STR_SIZE,
|
||||
"[{iov_base=\"%s\\0\", iov_len=%zu}, "
|
||||
diff --git a/tests/lock_file.c b/tests/lock_file.c
|
||||
index 56cf112..7618552 100644
|
||||
--- a/tests/lock_file.c
|
||||
+++ b/tests/lock_file.c
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "tests.h"
|
||||
+#include "xmalloc.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
@@ -21,9 +22,7 @@ lock_file_by_dirname(const char *path_name, const char *lock_name)
|
||||
const char *slash = path_name ? strrchr(path_name, '/') : NULL;
|
||||
const int plen = slash ? (int) (slash - path_name) + 1 : 0;
|
||||
|
||||
- char *lock_file = NULL;
|
||||
- if (asprintf(&lock_file, "%.*s%s", plen, path_name, lock_name) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *lock_file = xasprintf("%.*s%s", plen, path_name, lock_name);
|
||||
|
||||
int lock_fd = open(lock_file, O_RDONLY);
|
||||
if (lock_fd < 0)
|
||||
diff --git a/tests/mq.c b/tests/mq.c
|
||||
index a083e5a..7aa0914 100644
|
||||
--- a/tests/mq.c
|
||||
+++ b/tests/mq.c
|
||||
@@ -17,6 +17,7 @@
|
||||
# include <stdlib.h>
|
||||
# include <unistd.h>
|
||||
# include <sys/stat.h>
|
||||
+# include "xmalloc.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
@@ -24,9 +25,7 @@ main(void)
|
||||
struct mq_attr attr;
|
||||
(void) close(0);
|
||||
|
||||
- char *name;
|
||||
- if (asprintf(&name, "/strace-mq-%u.sample", getpid()) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *name = xasprintf("/strace-mq-%u.sample", getpid());
|
||||
|
||||
if (mq_open(name, O_CREAT, 0700, NULL))
|
||||
perror_msg_and_skip("mq_open");
|
||||
diff --git a/tests/mq_sendrecv.c b/tests/mq_sendrecv.c
|
||||
index 45ddf5e..5a919c4 100644
|
||||
--- a/tests/mq_sendrecv.c
|
||||
+++ b/tests/mq_sendrecv.c
|
||||
@@ -27,6 +27,7 @@
|
||||
# include <time.h>
|
||||
# include <unistd.h>
|
||||
|
||||
+# include "xmalloc.h"
|
||||
# include "sigevent.h"
|
||||
|
||||
# ifndef DUMPIO_READ
|
||||
@@ -407,8 +408,7 @@ main(void)
|
||||
|
||||
/* Sending and receiving test */
|
||||
|
||||
- if (asprintf(&mq_name, "strace-mq_sendrecv-%u.sample", getpid()) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ mq_name = xasprintf("strace-mq_sendrecv-%u.sample", getpid());
|
||||
|
||||
# if DUMPIO_READ || DUMPIO_WRITE
|
||||
close(0);
|
||||
diff --git a/tests/netlink_protocol.c b/tests/netlink_protocol.c
|
||||
index e632ba3..c37489f 100644
|
||||
--- a/tests/netlink_protocol.c
|
||||
+++ b/tests/netlink_protocol.c
|
||||
@@ -22,6 +22,7 @@
|
||||
# include "netlink.h"
|
||||
# include <linux/sock_diag.h>
|
||||
# include <linux/netlink_diag.h>
|
||||
+# include "xmalloc.h"
|
||||
|
||||
static void
|
||||
send_query(const int fd)
|
||||
@@ -388,9 +389,7 @@ int main(void)
|
||||
{
|
||||
const int fd = create_nl_socket(NETLINK_SOCK_DIAG);
|
||||
|
||||
- char *path;
|
||||
- if (asprintf(&path, "/proc/self/fd/%u", fd) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *path = xasprintf("/proc/self/fd/%u", fd);
|
||||
char buf[256];
|
||||
if (getxattr(path, "system.sockprotoname", buf, sizeof(buf) - 1) < 0)
|
||||
perror_msg_and_skip("getxattr");
|
||||
diff --git a/tests/old_mmap.c b/tests/old_mmap.c
|
||||
index f095bc4..bb70359 100644
|
||||
--- a/tests/old_mmap.c
|
||||
+++ b/tests/old_mmap.c
|
||||
@@ -27,6 +27,7 @@
|
||||
# include <string.h>
|
||||
# include <sys/mman.h>
|
||||
# include <unistd.h>
|
||||
+# include "xmalloc.h"
|
||||
|
||||
# ifndef TEST_FD
|
||||
# define TEST_FD -2LU
|
||||
@@ -82,9 +83,7 @@ main(void)
|
||||
# ifndef PATH_TRACING
|
||||
const char *errstr;
|
||||
if (implemented) {
|
||||
- char *str;
|
||||
- if (asprintf(&str, "%#lx", rc) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *str = xasprintf("%#lx", rc);
|
||||
errstr = str;
|
||||
} else {
|
||||
errstr = sprintrc(rc);
|
||||
diff --git a/tests/tracer_ppid_pgid_sid.c b/tests/tracer_ppid_pgid_sid.c
|
||||
index 69687fa..ce9936d 100644
|
||||
--- a/tests/tracer_ppid_pgid_sid.c
|
||||
+++ b/tests/tracer_ppid_pgid_sid.c
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "tests.h"
|
||||
+#include "xmalloc.h"
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -55,10 +56,7 @@ get_tracer_pid(void)
|
||||
static void
|
||||
get_ppid_pgid_sid(int pid, int *ppid, int *pgid, int *sid)
|
||||
{
|
||||
- char *stat;
|
||||
- if (asprintf(&stat, "/proc/%d/stat", pid) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
-
|
||||
+ char *stat = xasprintf("/proc/%d/stat", pid);
|
||||
FILE *fp = fopen(stat, "r");
|
||||
if (!fp)
|
||||
perror_msg_and_fail("fopen: %s", stat);
|
||||
diff --git a/tests-m32/clone-flags.c b/tests-m32/clone-flags.c
|
||||
index 04bb2c7..aa7d48c 100644
|
||||
--- a/tests-m32/clone-flags.c
|
||||
+++ b/tests-m32/clone-flags.c
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "tests.h"
|
||||
+#include "xmalloc.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
@@ -134,9 +135,7 @@ main(void)
|
||||
*ptid = 0;
|
||||
pid = do_clone(child, child_stack, child_stack_size,
|
||||
CLONE_PIDFD|SIGCHLD, 0, ptid);
|
||||
- char *fname = 0;
|
||||
- if (asprintf(&fname, "/proc/self/fd/%d", *ptid) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *fname = xasprintf("/proc/self/fd/%d", *ptid);
|
||||
int rc = readlink(fname, buf, sizeof(buf) - 1);
|
||||
if ((unsigned int) rc >= sizeof(buf))
|
||||
perror_msg_and_fail("readlink");
|
||||
diff --git a/tests-m32/faccessat.c b/tests-m32/faccessat.c
|
||||
index c42aa2d..8cda6f3 100644
|
||||
--- a/tests-m32/faccessat.c
|
||||
+++ b/tests-m32/faccessat.c
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#ifdef __NR_faccessat
|
||||
|
||||
+# include "xmalloc.h"
|
||||
# include <fcntl.h>
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
@@ -48,13 +49,9 @@ main(void)
|
||||
SKIP_IF_PROC_IS_UNAVAILABLE;
|
||||
|
||||
TAIL_ALLOC_OBJECT_CONST_PTR(const char, unterminated);
|
||||
- char *unterminated_str;
|
||||
- if (asprintf(&unterminated_str, "%p", unterminated) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *unterminated_str = xasprintf("%p", unterminated);
|
||||
const void *const efault = unterminated + 1;
|
||||
- char *efault_str;
|
||||
- if (asprintf(&efault_str, "%p", efault) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *efault_str = xasprintf("%p", efault);
|
||||
|
||||
typedef struct {
|
||||
char sym;
|
||||
@@ -75,12 +72,8 @@ main(void)
|
||||
int fd = open(path, O_WRONLY);
|
||||
if (fd < 0)
|
||||
perror_msg_and_fail("open: %s", path);
|
||||
- char *fd_str;
|
||||
- if (asprintf(&fd_str, "%d%s", fd, FD_PATH) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
- char *path_quoted;
|
||||
- if (asprintf(&path_quoted, "\"%s\"", path) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *fd_str = xasprintf("%d%s", fd, FD_PATH);
|
||||
+ char *path_quoted = xasprintf("\"%s\"", path);
|
||||
|
||||
struct {
|
||||
int val;
|
||||
diff --git a/tests-m32/ioctl_kvm_run_common.c b/tests-m32/ioctl_kvm_run_common.c
|
||||
index 9107c30..be1190e 100644
|
||||
--- a/tests-m32/ioctl_kvm_run_common.c
|
||||
+++ b/tests-m32/ioctl_kvm_run_common.c
|
||||
@@ -48,6 +48,7 @@
|
||||
# define KVM_MAX_CPUID_ENTRIES 80
|
||||
# endif
|
||||
|
||||
+# include "xmalloc.h"
|
||||
# include "xlat.h"
|
||||
# include "xlat/kvm_cpuid_flags.h"
|
||||
|
||||
@@ -254,12 +255,9 @@ static int
|
||||
vcpu_dev_should_have_cpuid(int fd)
|
||||
{
|
||||
int r = 0;
|
||||
- char *filename = NULL;
|
||||
+ char *filename = xasprintf("/proc/%d/fd/%d", getpid(), fd);
|
||||
char buf[sizeof(vcpu_dev)];
|
||||
|
||||
- if (asprintf(&filename, "/proc/%d/fd/%d", getpid(), fd) < 0)
|
||||
- error_msg_and_fail("asprintf");
|
||||
-
|
||||
if (readlink(filename, buf, sizeof(buf)) == sizeof(buf) - 1
|
||||
&& (memcmp(buf, vcpu_dev, sizeof(buf) - 1) == 0))
|
||||
r = 1;
|
||||
diff --git a/tests-m32/keyctl.c b/tests-m32/keyctl.c
|
||||
index 6dc30fb..96ac197 100644
|
||||
--- a/tests-m32/keyctl.c
|
||||
+++ b/tests-m32/keyctl.c
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "tests.h"
|
||||
|
||||
#include "scno.h"
|
||||
+#include "xmalloc.h"
|
||||
|
||||
#ifdef __NR_keyctl
|
||||
|
||||
@@ -445,7 +446,6 @@ main(void)
|
||||
struct iovec *key_iov = tail_alloc(sizeof(*key_iov) * IOV_SIZE);
|
||||
char *bogus_buf1 = tail_alloc(9);
|
||||
char *bogus_buf2 = tail_alloc(256);
|
||||
- char *key_iov_str1;
|
||||
char *key_iov_str2 = tail_alloc(4096);
|
||||
const char *errstr;
|
||||
ssize_t ret;
|
||||
@@ -472,21 +472,18 @@ main(void)
|
||||
0x100000001ULL * i);
|
||||
}
|
||||
|
||||
- ret = asprintf(&key_iov_str1, "[{iov_base=%p, iov_len=%zu}, "
|
||||
- "{iov_base=%p, iov_len=%zu}, "
|
||||
- "{iov_base=%p, iov_len=%zu}, "
|
||||
- "{iov_base=%p, iov_len=%zu}]",
|
||||
- key_iov[IOV_SIZE - 4].iov_base,
|
||||
- key_iov[IOV_SIZE - 4].iov_len,
|
||||
- key_iov[IOV_SIZE - 3].iov_base,
|
||||
- key_iov[IOV_SIZE - 3].iov_len,
|
||||
- key_iov[IOV_SIZE - 2].iov_base,
|
||||
- key_iov[IOV_SIZE - 2].iov_len,
|
||||
- key_iov[IOV_SIZE - 1].iov_base,
|
||||
- key_iov[IOV_SIZE - 1].iov_len);
|
||||
-
|
||||
- if (ret < 0)
|
||||
- error_msg_and_fail("asprintf");
|
||||
+ char *key_iov_str1 = xasprintf("[{iov_base=%p, iov_len=%zu}, "
|
||||
+ "{iov_base=%p, iov_len=%zu}, "
|
||||
+ "{iov_base=%p, iov_len=%zu}, "
|
||||
+ "{iov_base=%p, iov_len=%zu}]",
|
||||
+ key_iov[IOV_SIZE - 4].iov_base,
|
||||
+ key_iov[IOV_SIZE - 4].iov_len,
|
||||
+ key_iov[IOV_SIZE - 3].iov_base,
|
||||
+ key_iov[IOV_SIZE - 3].iov_len,
|
||||
+ key_iov[IOV_SIZE - 2].iov_base,
|
||||
+ key_iov[IOV_SIZE - 2].iov_len,
|
||||
+ key_iov[IOV_SIZE - 1].iov_base,
|
||||
+ key_iov[IOV_SIZE - 1].iov_len);
|
||||
|
||||
ret = snprintf(key_iov_str2, IOV_STR_SIZE,
|
||||
"[{iov_base=\"%s\\0\", iov_len=%zu}, "
|
||||
diff --git a/tests-m32/lock_file.c b/tests-m32/lock_file.c
|
||||
index 56cf112..7618552 100644
|
||||
--- a/tests-m32/lock_file.c
|
||||
+++ b/tests-m32/lock_file.c
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "tests.h"
|
||||
+#include "xmalloc.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
@@ -21,9 +22,7 @@ lock_file_by_dirname(const char *path_name, const char *lock_name)
|
||||
const char *slash = path_name ? strrchr(path_name, '/') : NULL;
|
||||
const int plen = slash ? (int) (slash - path_name) + 1 : 0;
|
||||
|
||||
- char *lock_file = NULL;
|
||||
- if (asprintf(&lock_file, "%.*s%s", plen, path_name, lock_name) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *lock_file = xasprintf("%.*s%s", plen, path_name, lock_name);
|
||||
|
||||
int lock_fd = open(lock_file, O_RDONLY);
|
||||
if (lock_fd < 0)
|
||||
diff --git a/tests-m32/mq.c b/tests-m32/mq.c
|
||||
index a083e5a..7aa0914 100644
|
||||
--- a/tests-m32/mq.c
|
||||
+++ b/tests-m32/mq.c
|
||||
@@ -17,6 +17,7 @@
|
||||
# include <stdlib.h>
|
||||
# include <unistd.h>
|
||||
# include <sys/stat.h>
|
||||
+# include "xmalloc.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
@@ -24,9 +25,7 @@ main(void)
|
||||
struct mq_attr attr;
|
||||
(void) close(0);
|
||||
|
||||
- char *name;
|
||||
- if (asprintf(&name, "/strace-mq-%u.sample", getpid()) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *name = xasprintf("/strace-mq-%u.sample", getpid());
|
||||
|
||||
if (mq_open(name, O_CREAT, 0700, NULL))
|
||||
perror_msg_and_skip("mq_open");
|
||||
diff --git a/tests-m32/mq_sendrecv.c b/tests-m32/mq_sendrecv.c
|
||||
index 45ddf5e..5a919c4 100644
|
||||
--- a/tests-m32/mq_sendrecv.c
|
||||
+++ b/tests-m32/mq_sendrecv.c
|
||||
@@ -27,6 +27,7 @@
|
||||
# include <time.h>
|
||||
# include <unistd.h>
|
||||
|
||||
+# include "xmalloc.h"
|
||||
# include "sigevent.h"
|
||||
|
||||
# ifndef DUMPIO_READ
|
||||
@@ -407,8 +408,7 @@ main(void)
|
||||
|
||||
/* Sending and receiving test */
|
||||
|
||||
- if (asprintf(&mq_name, "strace-mq_sendrecv-%u.sample", getpid()) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ mq_name = xasprintf("strace-mq_sendrecv-%u.sample", getpid());
|
||||
|
||||
# if DUMPIO_READ || DUMPIO_WRITE
|
||||
close(0);
|
||||
diff --git a/tests-m32/netlink_protocol.c b/tests-m32/netlink_protocol.c
|
||||
index e632ba3..c37489f 100644
|
||||
--- a/tests-m32/netlink_protocol.c
|
||||
+++ b/tests-m32/netlink_protocol.c
|
||||
@@ -22,6 +22,7 @@
|
||||
# include "netlink.h"
|
||||
# include <linux/sock_diag.h>
|
||||
# include <linux/netlink_diag.h>
|
||||
+# include "xmalloc.h"
|
||||
|
||||
static void
|
||||
send_query(const int fd)
|
||||
@@ -388,9 +389,7 @@ int main(void)
|
||||
{
|
||||
const int fd = create_nl_socket(NETLINK_SOCK_DIAG);
|
||||
|
||||
- char *path;
|
||||
- if (asprintf(&path, "/proc/self/fd/%u", fd) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *path = xasprintf("/proc/self/fd/%u", fd);
|
||||
char buf[256];
|
||||
if (getxattr(path, "system.sockprotoname", buf, sizeof(buf) - 1) < 0)
|
||||
perror_msg_and_skip("getxattr");
|
||||
diff --git a/tests-m32/old_mmap.c b/tests-m32/old_mmap.c
|
||||
index f095bc4..bb70359 100644
|
||||
--- a/tests-m32/old_mmap.c
|
||||
+++ b/tests-m32/old_mmap.c
|
||||
@@ -27,6 +27,7 @@
|
||||
# include <string.h>
|
||||
# include <sys/mman.h>
|
||||
# include <unistd.h>
|
||||
+# include "xmalloc.h"
|
||||
|
||||
# ifndef TEST_FD
|
||||
# define TEST_FD -2LU
|
||||
@@ -82,9 +83,7 @@ main(void)
|
||||
# ifndef PATH_TRACING
|
||||
const char *errstr;
|
||||
if (implemented) {
|
||||
- char *str;
|
||||
- if (asprintf(&str, "%#lx", rc) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *str = xasprintf("%#lx", rc);
|
||||
errstr = str;
|
||||
} else {
|
||||
errstr = sprintrc(rc);
|
||||
diff --git a/tests-m32/tracer_ppid_pgid_sid.c b/tests-m32/tracer_ppid_pgid_sid.c
|
||||
index 69687fa..ce9936d 100644
|
||||
--- a/tests-m32/tracer_ppid_pgid_sid.c
|
||||
+++ b/tests-m32/tracer_ppid_pgid_sid.c
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "tests.h"
|
||||
+#include "xmalloc.h"
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -55,10 +56,7 @@ get_tracer_pid(void)
|
||||
static void
|
||||
get_ppid_pgid_sid(int pid, int *ppid, int *pgid, int *sid)
|
||||
{
|
||||
- char *stat;
|
||||
- if (asprintf(&stat, "/proc/%d/stat", pid) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
-
|
||||
+ char *stat = xasprintf("/proc/%d/stat", pid);
|
||||
FILE *fp = fopen(stat, "r");
|
||||
if (!fp)
|
||||
perror_msg_and_fail("fopen: %s", stat);
|
||||
diff --git a/tests-mx32/clone-flags.c b/tests-mx32/clone-flags.c
|
||||
index 04bb2c7..aa7d48c 100644
|
||||
--- a/tests-mx32/clone-flags.c
|
||||
+++ b/tests-mx32/clone-flags.c
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "tests.h"
|
||||
+#include "xmalloc.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
@@ -134,9 +135,7 @@ main(void)
|
||||
*ptid = 0;
|
||||
pid = do_clone(child, child_stack, child_stack_size,
|
||||
CLONE_PIDFD|SIGCHLD, 0, ptid);
|
||||
- char *fname = 0;
|
||||
- if (asprintf(&fname, "/proc/self/fd/%d", *ptid) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *fname = xasprintf("/proc/self/fd/%d", *ptid);
|
||||
int rc = readlink(fname, buf, sizeof(buf) - 1);
|
||||
if ((unsigned int) rc >= sizeof(buf))
|
||||
perror_msg_and_fail("readlink");
|
||||
diff --git a/tests-mx32/faccessat.c b/tests-mx32/faccessat.c
|
||||
index c42aa2d..8cda6f3 100644
|
||||
--- a/tests-mx32/faccessat.c
|
||||
+++ b/tests-mx32/faccessat.c
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#ifdef __NR_faccessat
|
||||
|
||||
+# include "xmalloc.h"
|
||||
# include <fcntl.h>
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
@@ -48,13 +49,9 @@ main(void)
|
||||
SKIP_IF_PROC_IS_UNAVAILABLE;
|
||||
|
||||
TAIL_ALLOC_OBJECT_CONST_PTR(const char, unterminated);
|
||||
- char *unterminated_str;
|
||||
- if (asprintf(&unterminated_str, "%p", unterminated) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *unterminated_str = xasprintf("%p", unterminated);
|
||||
const void *const efault = unterminated + 1;
|
||||
- char *efault_str;
|
||||
- if (asprintf(&efault_str, "%p", efault) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *efault_str = xasprintf("%p", efault);
|
||||
|
||||
typedef struct {
|
||||
char sym;
|
||||
@@ -75,12 +72,8 @@ main(void)
|
||||
int fd = open(path, O_WRONLY);
|
||||
if (fd < 0)
|
||||
perror_msg_and_fail("open: %s", path);
|
||||
- char *fd_str;
|
||||
- if (asprintf(&fd_str, "%d%s", fd, FD_PATH) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
- char *path_quoted;
|
||||
- if (asprintf(&path_quoted, "\"%s\"", path) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *fd_str = xasprintf("%d%s", fd, FD_PATH);
|
||||
+ char *path_quoted = xasprintf("\"%s\"", path);
|
||||
|
||||
struct {
|
||||
int val;
|
||||
diff --git a/tests-mx32/ioctl_kvm_run_common.c b/tests-mx32/ioctl_kvm_run_common.c
|
||||
index 9107c30..be1190e 100644
|
||||
--- a/tests-mx32/ioctl_kvm_run_common.c
|
||||
+++ b/tests-mx32/ioctl_kvm_run_common.c
|
||||
@@ -48,6 +48,7 @@
|
||||
# define KVM_MAX_CPUID_ENTRIES 80
|
||||
# endif
|
||||
|
||||
+# include "xmalloc.h"
|
||||
# include "xlat.h"
|
||||
# include "xlat/kvm_cpuid_flags.h"
|
||||
|
||||
@@ -254,12 +255,9 @@ static int
|
||||
vcpu_dev_should_have_cpuid(int fd)
|
||||
{
|
||||
int r = 0;
|
||||
- char *filename = NULL;
|
||||
+ char *filename = xasprintf("/proc/%d/fd/%d", getpid(), fd);
|
||||
char buf[sizeof(vcpu_dev)];
|
||||
|
||||
- if (asprintf(&filename, "/proc/%d/fd/%d", getpid(), fd) < 0)
|
||||
- error_msg_and_fail("asprintf");
|
||||
-
|
||||
if (readlink(filename, buf, sizeof(buf)) == sizeof(buf) - 1
|
||||
&& (memcmp(buf, vcpu_dev, sizeof(buf) - 1) == 0))
|
||||
r = 1;
|
||||
diff --git a/tests-mx32/keyctl.c b/tests-mx32/keyctl.c
|
||||
index 6dc30fb..96ac197 100644
|
||||
--- a/tests-mx32/keyctl.c
|
||||
+++ b/tests-mx32/keyctl.c
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "tests.h"
|
||||
|
||||
#include "scno.h"
|
||||
+#include "xmalloc.h"
|
||||
|
||||
#ifdef __NR_keyctl
|
||||
|
||||
@@ -445,7 +446,6 @@ main(void)
|
||||
struct iovec *key_iov = tail_alloc(sizeof(*key_iov) * IOV_SIZE);
|
||||
char *bogus_buf1 = tail_alloc(9);
|
||||
char *bogus_buf2 = tail_alloc(256);
|
||||
- char *key_iov_str1;
|
||||
char *key_iov_str2 = tail_alloc(4096);
|
||||
const char *errstr;
|
||||
ssize_t ret;
|
||||
@@ -472,21 +472,18 @@ main(void)
|
||||
0x100000001ULL * i);
|
||||
}
|
||||
|
||||
- ret = asprintf(&key_iov_str1, "[{iov_base=%p, iov_len=%zu}, "
|
||||
- "{iov_base=%p, iov_len=%zu}, "
|
||||
- "{iov_base=%p, iov_len=%zu}, "
|
||||
- "{iov_base=%p, iov_len=%zu}]",
|
||||
- key_iov[IOV_SIZE - 4].iov_base,
|
||||
- key_iov[IOV_SIZE - 4].iov_len,
|
||||
- key_iov[IOV_SIZE - 3].iov_base,
|
||||
- key_iov[IOV_SIZE - 3].iov_len,
|
||||
- key_iov[IOV_SIZE - 2].iov_base,
|
||||
- key_iov[IOV_SIZE - 2].iov_len,
|
||||
- key_iov[IOV_SIZE - 1].iov_base,
|
||||
- key_iov[IOV_SIZE - 1].iov_len);
|
||||
-
|
||||
- if (ret < 0)
|
||||
- error_msg_and_fail("asprintf");
|
||||
+ char *key_iov_str1 = xasprintf("[{iov_base=%p, iov_len=%zu}, "
|
||||
+ "{iov_base=%p, iov_len=%zu}, "
|
||||
+ "{iov_base=%p, iov_len=%zu}, "
|
||||
+ "{iov_base=%p, iov_len=%zu}]",
|
||||
+ key_iov[IOV_SIZE - 4].iov_base,
|
||||
+ key_iov[IOV_SIZE - 4].iov_len,
|
||||
+ key_iov[IOV_SIZE - 3].iov_base,
|
||||
+ key_iov[IOV_SIZE - 3].iov_len,
|
||||
+ key_iov[IOV_SIZE - 2].iov_base,
|
||||
+ key_iov[IOV_SIZE - 2].iov_len,
|
||||
+ key_iov[IOV_SIZE - 1].iov_base,
|
||||
+ key_iov[IOV_SIZE - 1].iov_len);
|
||||
|
||||
ret = snprintf(key_iov_str2, IOV_STR_SIZE,
|
||||
"[{iov_base=\"%s\\0\", iov_len=%zu}, "
|
||||
diff --git a/tests-mx32/lock_file.c b/tests-mx32/lock_file.c
|
||||
index 56cf112..7618552 100644
|
||||
--- a/tests-mx32/lock_file.c
|
||||
+++ b/tests-mx32/lock_file.c
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "tests.h"
|
||||
+#include "xmalloc.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
@@ -21,9 +22,7 @@ lock_file_by_dirname(const char *path_name, const char *lock_name)
|
||||
const char *slash = path_name ? strrchr(path_name, '/') : NULL;
|
||||
const int plen = slash ? (int) (slash - path_name) + 1 : 0;
|
||||
|
||||
- char *lock_file = NULL;
|
||||
- if (asprintf(&lock_file, "%.*s%s", plen, path_name, lock_name) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *lock_file = xasprintf("%.*s%s", plen, path_name, lock_name);
|
||||
|
||||
int lock_fd = open(lock_file, O_RDONLY);
|
||||
if (lock_fd < 0)
|
||||
diff --git a/tests-mx32/mq.c b/tests-mx32/mq.c
|
||||
index a083e5a..7aa0914 100644
|
||||
--- a/tests-mx32/mq.c
|
||||
+++ b/tests-mx32/mq.c
|
||||
@@ -17,6 +17,7 @@
|
||||
# include <stdlib.h>
|
||||
# include <unistd.h>
|
||||
# include <sys/stat.h>
|
||||
+# include "xmalloc.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
@@ -24,9 +25,7 @@ main(void)
|
||||
struct mq_attr attr;
|
||||
(void) close(0);
|
||||
|
||||
- char *name;
|
||||
- if (asprintf(&name, "/strace-mq-%u.sample", getpid()) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *name = xasprintf("/strace-mq-%u.sample", getpid());
|
||||
|
||||
if (mq_open(name, O_CREAT, 0700, NULL))
|
||||
perror_msg_and_skip("mq_open");
|
||||
diff --git a/tests-mx32/mq_sendrecv.c b/tests-mx32/mq_sendrecv.c
|
||||
index 45ddf5e..5a919c4 100644
|
||||
--- a/tests-mx32/mq_sendrecv.c
|
||||
+++ b/tests-mx32/mq_sendrecv.c
|
||||
@@ -27,6 +27,7 @@
|
||||
# include <time.h>
|
||||
# include <unistd.h>
|
||||
|
||||
+# include "xmalloc.h"
|
||||
# include "sigevent.h"
|
||||
|
||||
# ifndef DUMPIO_READ
|
||||
@@ -407,8 +408,7 @@ main(void)
|
||||
|
||||
/* Sending and receiving test */
|
||||
|
||||
- if (asprintf(&mq_name, "strace-mq_sendrecv-%u.sample", getpid()) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ mq_name = xasprintf("strace-mq_sendrecv-%u.sample", getpid());
|
||||
|
||||
# if DUMPIO_READ || DUMPIO_WRITE
|
||||
close(0);
|
||||
diff --git a/tests-mx32/netlink_protocol.c b/tests-mx32/netlink_protocol.c
|
||||
index e632ba3..c37489f 100644
|
||||
--- a/tests-mx32/netlink_protocol.c
|
||||
+++ b/tests-mx32/netlink_protocol.c
|
||||
@@ -22,6 +22,7 @@
|
||||
# include "netlink.h"
|
||||
# include <linux/sock_diag.h>
|
||||
# include <linux/netlink_diag.h>
|
||||
+# include "xmalloc.h"
|
||||
|
||||
static void
|
||||
send_query(const int fd)
|
||||
@@ -388,9 +389,7 @@ int main(void)
|
||||
{
|
||||
const int fd = create_nl_socket(NETLINK_SOCK_DIAG);
|
||||
|
||||
- char *path;
|
||||
- if (asprintf(&path, "/proc/self/fd/%u", fd) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *path = xasprintf("/proc/self/fd/%u", fd);
|
||||
char buf[256];
|
||||
if (getxattr(path, "system.sockprotoname", buf, sizeof(buf) - 1) < 0)
|
||||
perror_msg_and_skip("getxattr");
|
||||
diff --git a/tests-mx32/old_mmap.c b/tests-mx32/old_mmap.c
|
||||
index f095bc4..bb70359 100644
|
||||
--- a/tests-mx32/old_mmap.c
|
||||
+++ b/tests-mx32/old_mmap.c
|
||||
@@ -27,6 +27,7 @@
|
||||
# include <string.h>
|
||||
# include <sys/mman.h>
|
||||
# include <unistd.h>
|
||||
+# include "xmalloc.h"
|
||||
|
||||
# ifndef TEST_FD
|
||||
# define TEST_FD -2LU
|
||||
@@ -82,9 +83,7 @@ main(void)
|
||||
# ifndef PATH_TRACING
|
||||
const char *errstr;
|
||||
if (implemented) {
|
||||
- char *str;
|
||||
- if (asprintf(&str, "%#lx", rc) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
+ char *str = xasprintf("%#lx", rc);
|
||||
errstr = str;
|
||||
} else {
|
||||
errstr = sprintrc(rc);
|
||||
diff --git a/tests-mx32/tracer_ppid_pgid_sid.c b/tests-mx32/tracer_ppid_pgid_sid.c
|
||||
index 69687fa..ce9936d 100644
|
||||
--- a/tests-mx32/tracer_ppid_pgid_sid.c
|
||||
+++ b/tests-mx32/tracer_ppid_pgid_sid.c
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "tests.h"
|
||||
+#include "xmalloc.h"
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -55,10 +56,7 @@ get_tracer_pid(void)
|
||||
static void
|
||||
get_ppid_pgid_sid(int pid, int *ppid, int *pgid, int *sid)
|
||||
{
|
||||
- char *stat;
|
||||
- if (asprintf(&stat, "/proc/%d/stat", pid) < 0)
|
||||
- perror_msg_and_fail("asprintf");
|
||||
-
|
||||
+ char *stat = xasprintf("/proc/%d/stat", pid);
|
||||
FILE *fp = fopen(stat, "r");
|
||||
if (!fp)
|
||||
perror_msg_and_fail("fopen: %s", stat);
|
||||
--
|
||||
2.1.4
|
||||
|
@ -0,0 +1,276 @@
|
||||
From 5a8d3bab6f492b3932299d9e80fb247ab00b8102 Mon Sep 17 00:00:00 2001
|
||||
From: "Dmitry V. Levin" <ldv@strace.io>
|
||||
Date: Sun, 7 Mar 2021 08:00:00 +0000
|
||||
Subject: [PATCH 147/149] file_handle: print f_handle as a hexadecimal string
|
||||
|
||||
Printing the sequence of bytes as a hexadecimal number is misleading
|
||||
because the latter depends on endianness.
|
||||
|
||||
* src/file_handle.c (print_f_handle): New function.
|
||||
(SYS_FUNC(name_to_handle_at), SYS_FUNC(open_by_handle_at)): Use it
|
||||
to print struct file_handle.f_handle.
|
||||
* tests/file_handle.c (print_handle_data, do_open_by_handle_at, main):
|
||||
Update expected output.
|
||||
---
|
||||
file_handle.c | 47 ++++++++++++++++++++++-------------------------
|
||||
tests/file_handle.c | 26 +++++++++++---------------
|
||||
2 files changed, 33 insertions(+), 40 deletions(-)
|
||||
|
||||
diff --git a/file_handle.c b/file_handle.c
|
||||
index d82a1bc..343111f 100644
|
||||
--- a/file_handle.c
|
||||
+++ b/file_handle.c
|
||||
@@ -19,6 +19,22 @@ typedef struct {
|
||||
int handle_type;
|
||||
} file_handle_header;
|
||||
|
||||
+static void
|
||||
+print_f_handle(struct tcb *tcp, kernel_ulong_t addr, unsigned int handle_bytes)
|
||||
+{
|
||||
+ unsigned int len = MIN(handle_bytes, MAX_HANDLE_SZ);
|
||||
+ char f_handle[MAX_HANDLE_SZ];
|
||||
+ addr += sizeof(file_handle_header);
|
||||
+ if (addr > sizeof(file_handle_header) &&
|
||||
+ !umoven(tcp, addr, len, f_handle)) {
|
||||
+ print_quoted_string(f_handle, len, QUOTE_FORCE_HEX);
|
||||
+ if (handle_bytes > len)
|
||||
+ tprints("...");
|
||||
+ } else {
|
||||
+ tprints("???");
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
SYS_FUNC(name_to_handle_at)
|
||||
{
|
||||
file_handle_header h;
|
||||
@@ -53,24 +69,15 @@ SYS_FUNC(name_to_handle_at)
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
- unsigned int i = get_tcb_priv_ulong(tcp);
|
||||
-
|
||||
if ((!syserror(tcp) || EOVERFLOW == tcp->u_error)
|
||||
&& !umove(tcp, addr, &h)) {
|
||||
- unsigned char f_handle[MAX_HANDLE_SZ];
|
||||
|
||||
- if (i != h.handle_bytes)
|
||||
+ if (h.handle_bytes != get_tcb_priv_ulong(tcp))
|
||||
tprintf(" => %u", h.handle_bytes);
|
||||
if (!syserror(tcp)) {
|
||||
- tprintf(", handle_type=%d", h.handle_type);
|
||||
- if (h.handle_bytes > MAX_HANDLE_SZ)
|
||||
- h.handle_bytes = MAX_HANDLE_SZ;
|
||||
- if (!umoven(tcp, addr + sizeof(h), h.handle_bytes,
|
||||
- f_handle)) {
|
||||
- tprints(", f_handle=0x");
|
||||
- for (i = 0; i < h.handle_bytes; ++i)
|
||||
- tprintf("%02x", f_handle[i]);
|
||||
- }
|
||||
+ tprintf(", handle_type=%d, f_handle=",
|
||||
+ h.handle_type);
|
||||
+ print_f_handle(tcp, addr, h.handle_bytes);
|
||||
}
|
||||
}
|
||||
tprints("}, ");
|
||||
@@ -96,19 +103,9 @@ SYS_FUNC(open_by_handle_at)
|
||||
|
||||
/* handle */
|
||||
if (!umove_or_printaddr(tcp, addr, &h)) {
|
||||
- unsigned char f_handle[MAX_HANDLE_SZ];
|
||||
-
|
||||
- tprintf("{handle_bytes=%u, handle_type=%d",
|
||||
+ tprintf("{handle_bytes=%u, handle_type=%d, f_handle=",
|
||||
h.handle_bytes, h.handle_type);
|
||||
- if (h.handle_bytes > MAX_HANDLE_SZ)
|
||||
- h.handle_bytes = MAX_HANDLE_SZ;
|
||||
- if (!umoven(tcp, addr + sizeof(h), h.handle_bytes, &f_handle)) {
|
||||
- unsigned int i;
|
||||
-
|
||||
- tprints(", f_handle=0x");
|
||||
- for (i = 0; i < h.handle_bytes; ++i)
|
||||
- tprintf("%02x", f_handle[i]);
|
||||
- }
|
||||
+ print_f_handle(tcp, addr, h.handle_bytes);
|
||||
tprints("}");
|
||||
}
|
||||
tprints(", ");
|
||||
diff --git a/tests/file_handle.c b/tests/file_handle.c
|
||||
index edabde6..07af7ba 100644
|
||||
--- a/tests/file_handle.c
|
||||
+++ b/tests/file_handle.c
|
||||
@@ -42,14 +42,10 @@ struct file_handle {
|
||||
void
|
||||
print_handle_data(unsigned char *bytes, unsigned int size)
|
||||
{
|
||||
- unsigned int i;
|
||||
-
|
||||
- if (size > MAX_HANDLE_SZ)
|
||||
- size = MAX_HANDLE_SZ;
|
||||
-
|
||||
- printf("0x");
|
||||
- for (i = 0; i < size; ++i)
|
||||
- printf("%02x", bytes[i]);
|
||||
+ unsigned int len = MIN(size, MAX_HANDLE_SZ);
|
||||
+ print_quoted_hex(bytes, len);
|
||||
+ if (size > len)
|
||||
+ printf("...");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -111,11 +107,13 @@ do_open_by_handle_at(kernel_ulong_t mount_fd,
|
||||
printf("{handle_bytes=%u, handle_type=%d", fh->handle_bytes,
|
||||
fh->handle_type);
|
||||
|
||||
+ printf(", f_handle=");
|
||||
if (valid_data) {
|
||||
- printf(", f_handle=");
|
||||
print_handle_data((unsigned char *) fh +
|
||||
sizeof(struct file_handle),
|
||||
fh->handle_bytes);
|
||||
+ } else {
|
||||
+ printf("???");
|
||||
}
|
||||
|
||||
printf("}");
|
||||
@@ -275,16 +273,14 @@ main(void)
|
||||
assert(syscall(__NR_name_to_handle_at, fdcwd, ".", handle, &mount_id,
|
||||
flags) == 0);
|
||||
printf("name_to_handle_at(AT_FDCWD, \".\", {handle_bytes=%u"
|
||||
- ", handle_type=%d, f_handle=0x",
|
||||
+ ", handle_type=%d, f_handle=",
|
||||
handle->handle_bytes, handle->handle_type);
|
||||
- for (i = 0; i < handle->handle_bytes; ++i)
|
||||
- printf("%02x", handle->f_handle[i]);
|
||||
+ print_handle_data(handle->f_handle, handle->handle_bytes);
|
||||
printf("}, [%d], AT_SYMLINK_FOLLOW) = 0\n", mount_id);
|
||||
|
||||
printf("open_by_handle_at(-1, {handle_bytes=%u, handle_type=%d"
|
||||
- ", f_handle=0x", handle->handle_bytes, handle->handle_type);
|
||||
- for (i = 0; i < handle->handle_bytes; ++i)
|
||||
- printf("%02x", handle->f_handle[i]);
|
||||
+ ", f_handle=", handle->handle_bytes, handle->handle_type);
|
||||
+ print_handle_data(handle->f_handle, handle->handle_bytes);
|
||||
int rc = syscall(__NR_open_by_handle_at, -1, handle,
|
||||
O_RDONLY | O_DIRECTORY);
|
||||
printf("}, O_RDONLY|O_DIRECTORY) = %d %s (%m)\n", rc, errno2name());
|
||||
diff --git a/tests-m32/file_handle.c b/tests-m32/file_handle.c
|
||||
index edabde6..07af7ba 100644
|
||||
--- a/tests-m32/file_handle.c
|
||||
+++ b/tests-m32/file_handle.c
|
||||
@@ -42,14 +42,10 @@ struct file_handle {
|
||||
void
|
||||
print_handle_data(unsigned char *bytes, unsigned int size)
|
||||
{
|
||||
- unsigned int i;
|
||||
-
|
||||
- if (size > MAX_HANDLE_SZ)
|
||||
- size = MAX_HANDLE_SZ;
|
||||
-
|
||||
- printf("0x");
|
||||
- for (i = 0; i < size; ++i)
|
||||
- printf("%02x", bytes[i]);
|
||||
+ unsigned int len = MIN(size, MAX_HANDLE_SZ);
|
||||
+ print_quoted_hex(bytes, len);
|
||||
+ if (size > len)
|
||||
+ printf("...");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -111,11 +107,13 @@ do_open_by_handle_at(kernel_ulong_t mount_fd,
|
||||
printf("{handle_bytes=%u, handle_type=%d", fh->handle_bytes,
|
||||
fh->handle_type);
|
||||
|
||||
+ printf(", f_handle=");
|
||||
if (valid_data) {
|
||||
- printf(", f_handle=");
|
||||
print_handle_data((unsigned char *) fh +
|
||||
sizeof(struct file_handle),
|
||||
fh->handle_bytes);
|
||||
+ } else {
|
||||
+ printf("???");
|
||||
}
|
||||
|
||||
printf("}");
|
||||
@@ -275,16 +273,14 @@ main(void)
|
||||
assert(syscall(__NR_name_to_handle_at, fdcwd, ".", handle, &mount_id,
|
||||
flags) == 0);
|
||||
printf("name_to_handle_at(AT_FDCWD, \".\", {handle_bytes=%u"
|
||||
- ", handle_type=%d, f_handle=0x",
|
||||
+ ", handle_type=%d, f_handle=",
|
||||
handle->handle_bytes, handle->handle_type);
|
||||
- for (i = 0; i < handle->handle_bytes; ++i)
|
||||
- printf("%02x", handle->f_handle[i]);
|
||||
+ print_handle_data(handle->f_handle, handle->handle_bytes);
|
||||
printf("}, [%d], AT_SYMLINK_FOLLOW) = 0\n", mount_id);
|
||||
|
||||
printf("open_by_handle_at(-1, {handle_bytes=%u, handle_type=%d"
|
||||
- ", f_handle=0x", handle->handle_bytes, handle->handle_type);
|
||||
- for (i = 0; i < handle->handle_bytes; ++i)
|
||||
- printf("%02x", handle->f_handle[i]);
|
||||
+ ", f_handle=", handle->handle_bytes, handle->handle_type);
|
||||
+ print_handle_data(handle->f_handle, handle->handle_bytes);
|
||||
int rc = syscall(__NR_open_by_handle_at, -1, handle,
|
||||
O_RDONLY | O_DIRECTORY);
|
||||
printf("}, O_RDONLY|O_DIRECTORY) = %d %s (%m)\n", rc, errno2name());
|
||||
diff --git a/tests-mx32/file_handle.c b/tests-mx32/file_handle.c
|
||||
index edabde6..07af7ba 100644
|
||||
--- a/tests-mx32/file_handle.c
|
||||
+++ b/tests-mx32/file_handle.c
|
||||
@@ -42,14 +42,10 @@ struct file_handle {
|
||||
void
|
||||
print_handle_data(unsigned char *bytes, unsigned int size)
|
||||
{
|
||||
- unsigned int i;
|
||||
-
|
||||
- if (size > MAX_HANDLE_SZ)
|
||||
- size = MAX_HANDLE_SZ;
|
||||
-
|
||||
- printf("0x");
|
||||
- for (i = 0; i < size; ++i)
|
||||
- printf("%02x", bytes[i]);
|
||||
+ unsigned int len = MIN(size, MAX_HANDLE_SZ);
|
||||
+ print_quoted_hex(bytes, len);
|
||||
+ if (size > len)
|
||||
+ printf("...");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -111,11 +107,13 @@ do_open_by_handle_at(kernel_ulong_t mount_fd,
|
||||
printf("{handle_bytes=%u, handle_type=%d", fh->handle_bytes,
|
||||
fh->handle_type);
|
||||
|
||||
+ printf(", f_handle=");
|
||||
if (valid_data) {
|
||||
- printf(", f_handle=");
|
||||
print_handle_data((unsigned char *) fh +
|
||||
sizeof(struct file_handle),
|
||||
fh->handle_bytes);
|
||||
+ } else {
|
||||
+ printf("???");
|
||||
}
|
||||
|
||||
printf("}");
|
||||
@@ -275,16 +273,14 @@ main(void)
|
||||
assert(syscall(__NR_name_to_handle_at, fdcwd, ".", handle, &mount_id,
|
||||
flags) == 0);
|
||||
printf("name_to_handle_at(AT_FDCWD, \".\", {handle_bytes=%u"
|
||||
- ", handle_type=%d, f_handle=0x",
|
||||
+ ", handle_type=%d, f_handle=",
|
||||
handle->handle_bytes, handle->handle_type);
|
||||
- for (i = 0; i < handle->handle_bytes; ++i)
|
||||
- printf("%02x", handle->f_handle[i]);
|
||||
+ print_handle_data(handle->f_handle, handle->handle_bytes);
|
||||
printf("}, [%d], AT_SYMLINK_FOLLOW) = 0\n", mount_id);
|
||||
|
||||
printf("open_by_handle_at(-1, {handle_bytes=%u, handle_type=%d"
|
||||
- ", f_handle=0x", handle->handle_bytes, handle->handle_type);
|
||||
- for (i = 0; i < handle->handle_bytes; ++i)
|
||||
- printf("%02x", handle->f_handle[i]);
|
||||
+ ", f_handle=", handle->handle_bytes, handle->handle_type);
|
||||
+ print_handle_data(handle->f_handle, handle->handle_bytes);
|
||||
int rc = syscall(__NR_open_by_handle_at, -1, handle,
|
||||
O_RDONLY | O_DIRECTORY);
|
||||
printf("}, O_RDONLY|O_DIRECTORY) = %d %s (%m)\n", rc, errno2name());
|
||||
--
|
||||
2.1.4
|
||||
|
@ -0,0 +1,486 @@
|
||||
From 1ec648999d3bf01ae87cac65c810d5d8f19c71c0 Mon Sep 17 00:00:00 2001
|
||||
From: Sven Schnelle <svens@stackframe.org>
|
||||
Date: Tue, 10 Nov 2020 07:38:34 +0100
|
||||
Subject: [PATCH 148/149] tests: fix execve test with fresh linux kernels
|
||||
|
||||
Starting with Linux commit v5.9-rc1~164^2^2~2, execve copies syscall
|
||||
arguments before trying to find the executable, failing with EFAULT
|
||||
in case of a faulty address. Adjust the test to handle both variants
|
||||
of execve behaviour.
|
||||
|
||||
* tests/execve.c (errstr): New variable.
|
||||
(call_execve): New function.
|
||||
(main): Use it instead of execve. Do not hardcode ENOENT in expected
|
||||
output of tests, use errstr instead.
|
||||
|
||||
Signed-off-by: Sven Schnelle <svens@stackframe.org>
|
||||
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
|
||||
---
|
||||
tests/execve.c | 54 ++++++++++++++++++++++++++++++++----------------------
|
||||
1 file changed, 32 insertions(+), 22 deletions(-)
|
||||
|
||||
diff --git a/tests/execve.c b/tests/execve.c
|
||||
index 2f6ae52..961d284 100644
|
||||
--- a/tests/execve.c
|
||||
+++ b/tests/execve.c
|
||||
@@ -12,6 +12,16 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
+static const char *errstr;
|
||||
+
|
||||
+static int
|
||||
+call_execve(const char *pathname, char *const *argv, char *const *envp)
|
||||
+{
|
||||
+ int rc = execve(pathname, argv, envp);
|
||||
+ errstr = sprintrc(rc);
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
#define FILENAME "test.execve\nfilename"
|
||||
#define Q_FILENAME "test.execve\\nfilename"
|
||||
|
||||
@@ -43,7 +53,7 @@ main(void)
|
||||
char ** const tail_argv = tail_memdup(argv, sizeof(argv));
|
||||
char ** const tail_envp = tail_memdup(envp, sizeof(envp));
|
||||
|
||||
- execve(FILENAME, tail_argv, tail_envp);
|
||||
+ call_execve(FILENAME, tail_argv, tail_envp);
|
||||
printf("execve(\"%s\""
|
||||
", [\"%s\", \"%s\", \"%s\", %p, %p, %p, ... /* %p */]"
|
||||
#if VERBOSE
|
||||
@@ -51,7 +61,7 @@ main(void)
|
||||
#else
|
||||
", %p /* 5 vars, unterminated */"
|
||||
#endif
|
||||
- ") = -1 ENOENT (%m)\n",
|
||||
+ ") = %s\n",
|
||||
Q_FILENAME, q_argv[0], q_argv[1], q_argv[2],
|
||||
argv[3], argv[4], argv[5], (char *) tail_argv + sizeof(argv)
|
||||
#if VERBOSE
|
||||
@@ -60,60 +70,60 @@ main(void)
|
||||
#else
|
||||
, tail_envp
|
||||
#endif
|
||||
- );
|
||||
+ , errstr);
|
||||
|
||||
tail_argv[ARRAY_SIZE(q_argv)] = NULL;
|
||||
tail_envp[ARRAY_SIZE(q_envp)] = NULL;
|
||||
(void) q_envp; /* workaround for clang bug #33068 */
|
||||
|
||||
- execve(FILENAME, tail_argv, tail_envp);
|
||||
+ call_execve(FILENAME, tail_argv, tail_envp);
|
||||
printf("execve(\"%s\", [\"%s\", \"%s\", \"%s\"]"
|
||||
#if VERBOSE
|
||||
", [\"%s\", \"%s\"]"
|
||||
#else
|
||||
", %p /* 2 vars */"
|
||||
#endif
|
||||
- ") = -1 ENOENT (%m)\n",
|
||||
+ ") = %s\n",
|
||||
Q_FILENAME, q_argv[0], q_argv[1], q_argv[2]
|
||||
#if VERBOSE
|
||||
, q_envp[0], q_envp[1]
|
||||
#else
|
||||
, tail_envp
|
||||
#endif
|
||||
- );
|
||||
+ , errstr);
|
||||
|
||||
- execve(FILENAME, tail_argv + 2, tail_envp + 1);
|
||||
+ call_execve(FILENAME, tail_argv + 2, tail_envp + 1);
|
||||
printf("execve(\"%s\", [\"%s\"]"
|
||||
#if VERBOSE
|
||||
", [\"%s\"]"
|
||||
#else
|
||||
", %p /* 1 var */"
|
||||
#endif
|
||||
- ") = -1 ENOENT (%m)\n",
|
||||
+ ") = %s\n",
|
||||
Q_FILENAME, q_argv[2]
|
||||
#if VERBOSE
|
||||
, q_envp[1]
|
||||
#else
|
||||
, tail_envp + 1
|
||||
#endif
|
||||
- );
|
||||
+ , errstr);
|
||||
|
||||
TAIL_ALLOC_OBJECT_CONST_PTR(char *, empty);
|
||||
char **const efault = empty + 1;
|
||||
*empty = NULL;
|
||||
|
||||
- execve(FILENAME, empty, empty);
|
||||
+ call_execve(FILENAME, empty, empty);
|
||||
printf("execve(\"%s\", []"
|
||||
#if VERBOSE
|
||||
", []"
|
||||
#else
|
||||
", %p /* 0 vars */"
|
||||
#endif
|
||||
- ") = -1 ENOENT (%m)\n", Q_FILENAME
|
||||
+ ") = %s\n", Q_FILENAME
|
||||
#if !VERBOSE
|
||||
, empty
|
||||
#endif
|
||||
- );
|
||||
+ , errstr);
|
||||
|
||||
char *const str_a = tail_alloc(DEFAULT_STRLEN + 2);
|
||||
fill_memory_ex(str_a, DEFAULT_STRLEN + 1, '0', 10);
|
||||
@@ -132,7 +142,7 @@ main(void)
|
||||
}
|
||||
a[i] = b[i] = NULL;
|
||||
|
||||
- execve(FILENAME, a, b);
|
||||
+ call_execve(FILENAME, a, b);
|
||||
printf("execve(\"%s\", [\"%.*s\"...", Q_FILENAME, DEFAULT_STRLEN, a[0]);
|
||||
for (i = 1; i < DEFAULT_STRLEN; ++i)
|
||||
printf(", \"%s\"", a[i]);
|
||||
@@ -149,9 +159,9 @@ main(void)
|
||||
#else
|
||||
printf("], %p /* %u vars */", b, DEFAULT_STRLEN + 1);
|
||||
#endif
|
||||
- printf(") = -1 ENOENT (%m)\n");
|
||||
+ printf(") = %s\n", errstr);
|
||||
|
||||
- execve(FILENAME, a + 1, b + 1);
|
||||
+ call_execve(FILENAME, a + 1, b + 1);
|
||||
printf("execve(\"%s\", [\"%s\"", Q_FILENAME, a[1]);
|
||||
for (i = 2; i <= DEFAULT_STRLEN; ++i)
|
||||
printf(", \"%s\"", a[i]);
|
||||
@@ -163,15 +173,15 @@ main(void)
|
||||
#else
|
||||
printf("], %p /* %d vars */", b + 1, DEFAULT_STRLEN);
|
||||
#endif
|
||||
- printf(") = -1 ENOENT (%m)\n");
|
||||
+ printf(") = %s\n", errstr);
|
||||
|
||||
- execve(FILENAME, (char **) tail_argv[ARRAY_SIZE(q_argv)], efault);
|
||||
- printf("execve(\"%s\", NULL, %p) = -1 ENOENT (%m)\n",
|
||||
- Q_FILENAME, efault);
|
||||
+ call_execve(FILENAME, (char **) tail_argv[ARRAY_SIZE(q_argv)], efault);
|
||||
+ printf("execve(\"%s\", NULL, %p) = %s\n",
|
||||
+ Q_FILENAME, efault, errstr);
|
||||
|
||||
- execve(FILENAME, efault, NULL);
|
||||
- printf("execve(\"%s\", %p, NULL) = -1 ENOENT (%m)\n",
|
||||
- Q_FILENAME, efault);
|
||||
+ call_execve(FILENAME, efault, NULL);
|
||||
+ printf("execve(\"%s\", %p, NULL) = %s\n",
|
||||
+ Q_FILENAME, efault, errstr);
|
||||
|
||||
leave_and_remove_subdir();
|
||||
|
||||
diff --git a/tests-m32/execve.c b/tests-m32/execve.c
|
||||
index 2f6ae52..961d284 100644
|
||||
--- a/tests-m32/execve.c
|
||||
+++ b/tests-m32/execve.c
|
||||
@@ -12,6 +12,16 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
+static const char *errstr;
|
||||
+
|
||||
+static int
|
||||
+call_execve(const char *pathname, char *const *argv, char *const *envp)
|
||||
+{
|
||||
+ int rc = execve(pathname, argv, envp);
|
||||
+ errstr = sprintrc(rc);
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
#define FILENAME "test.execve\nfilename"
|
||||
#define Q_FILENAME "test.execve\\nfilename"
|
||||
|
||||
@@ -43,7 +53,7 @@ main(void)
|
||||
char ** const tail_argv = tail_memdup(argv, sizeof(argv));
|
||||
char ** const tail_envp = tail_memdup(envp, sizeof(envp));
|
||||
|
||||
- execve(FILENAME, tail_argv, tail_envp);
|
||||
+ call_execve(FILENAME, tail_argv, tail_envp);
|
||||
printf("execve(\"%s\""
|
||||
", [\"%s\", \"%s\", \"%s\", %p, %p, %p, ... /* %p */]"
|
||||
#if VERBOSE
|
||||
@@ -51,7 +61,7 @@ main(void)
|
||||
#else
|
||||
", %p /* 5 vars, unterminated */"
|
||||
#endif
|
||||
- ") = -1 ENOENT (%m)\n",
|
||||
+ ") = %s\n",
|
||||
Q_FILENAME, q_argv[0], q_argv[1], q_argv[2],
|
||||
argv[3], argv[4], argv[5], (char *) tail_argv + sizeof(argv)
|
||||
#if VERBOSE
|
||||
@@ -60,60 +70,60 @@ main(void)
|
||||
#else
|
||||
, tail_envp
|
||||
#endif
|
||||
- );
|
||||
+ , errstr);
|
||||
|
||||
tail_argv[ARRAY_SIZE(q_argv)] = NULL;
|
||||
tail_envp[ARRAY_SIZE(q_envp)] = NULL;
|
||||
(void) q_envp; /* workaround for clang bug #33068 */
|
||||
|
||||
- execve(FILENAME, tail_argv, tail_envp);
|
||||
+ call_execve(FILENAME, tail_argv, tail_envp);
|
||||
printf("execve(\"%s\", [\"%s\", \"%s\", \"%s\"]"
|
||||
#if VERBOSE
|
||||
", [\"%s\", \"%s\"]"
|
||||
#else
|
||||
", %p /* 2 vars */"
|
||||
#endif
|
||||
- ") = -1 ENOENT (%m)\n",
|
||||
+ ") = %s\n",
|
||||
Q_FILENAME, q_argv[0], q_argv[1], q_argv[2]
|
||||
#if VERBOSE
|
||||
, q_envp[0], q_envp[1]
|
||||
#else
|
||||
, tail_envp
|
||||
#endif
|
||||
- );
|
||||
+ , errstr);
|
||||
|
||||
- execve(FILENAME, tail_argv + 2, tail_envp + 1);
|
||||
+ call_execve(FILENAME, tail_argv + 2, tail_envp + 1);
|
||||
printf("execve(\"%s\", [\"%s\"]"
|
||||
#if VERBOSE
|
||||
", [\"%s\"]"
|
||||
#else
|
||||
", %p /* 1 var */"
|
||||
#endif
|
||||
- ") = -1 ENOENT (%m)\n",
|
||||
+ ") = %s\n",
|
||||
Q_FILENAME, q_argv[2]
|
||||
#if VERBOSE
|
||||
, q_envp[1]
|
||||
#else
|
||||
, tail_envp + 1
|
||||
#endif
|
||||
- );
|
||||
+ , errstr);
|
||||
|
||||
TAIL_ALLOC_OBJECT_CONST_PTR(char *, empty);
|
||||
char **const efault = empty + 1;
|
||||
*empty = NULL;
|
||||
|
||||
- execve(FILENAME, empty, empty);
|
||||
+ call_execve(FILENAME, empty, empty);
|
||||
printf("execve(\"%s\", []"
|
||||
#if VERBOSE
|
||||
", []"
|
||||
#else
|
||||
", %p /* 0 vars */"
|
||||
#endif
|
||||
- ") = -1 ENOENT (%m)\n", Q_FILENAME
|
||||
+ ") = %s\n", Q_FILENAME
|
||||
#if !VERBOSE
|
||||
, empty
|
||||
#endif
|
||||
- );
|
||||
+ , errstr);
|
||||
|
||||
char *const str_a = tail_alloc(DEFAULT_STRLEN + 2);
|
||||
fill_memory_ex(str_a, DEFAULT_STRLEN + 1, '0', 10);
|
||||
@@ -132,7 +142,7 @@ main(void)
|
||||
}
|
||||
a[i] = b[i] = NULL;
|
||||
|
||||
- execve(FILENAME, a, b);
|
||||
+ call_execve(FILENAME, a, b);
|
||||
printf("execve(\"%s\", [\"%.*s\"...", Q_FILENAME, DEFAULT_STRLEN, a[0]);
|
||||
for (i = 1; i < DEFAULT_STRLEN; ++i)
|
||||
printf(", \"%s\"", a[i]);
|
||||
@@ -149,9 +159,9 @@ main(void)
|
||||
#else
|
||||
printf("], %p /* %u vars */", b, DEFAULT_STRLEN + 1);
|
||||
#endif
|
||||
- printf(") = -1 ENOENT (%m)\n");
|
||||
+ printf(") = %s\n", errstr);
|
||||
|
||||
- execve(FILENAME, a + 1, b + 1);
|
||||
+ call_execve(FILENAME, a + 1, b + 1);
|
||||
printf("execve(\"%s\", [\"%s\"", Q_FILENAME, a[1]);
|
||||
for (i = 2; i <= DEFAULT_STRLEN; ++i)
|
||||
printf(", \"%s\"", a[i]);
|
||||
@@ -163,15 +173,15 @@ main(void)
|
||||
#else
|
||||
printf("], %p /* %d vars */", b + 1, DEFAULT_STRLEN);
|
||||
#endif
|
||||
- printf(") = -1 ENOENT (%m)\n");
|
||||
+ printf(") = %s\n", errstr);
|
||||
|
||||
- execve(FILENAME, (char **) tail_argv[ARRAY_SIZE(q_argv)], efault);
|
||||
- printf("execve(\"%s\", NULL, %p) = -1 ENOENT (%m)\n",
|
||||
- Q_FILENAME, efault);
|
||||
+ call_execve(FILENAME, (char **) tail_argv[ARRAY_SIZE(q_argv)], efault);
|
||||
+ printf("execve(\"%s\", NULL, %p) = %s\n",
|
||||
+ Q_FILENAME, efault, errstr);
|
||||
|
||||
- execve(FILENAME, efault, NULL);
|
||||
- printf("execve(\"%s\", %p, NULL) = -1 ENOENT (%m)\n",
|
||||
- Q_FILENAME, efault);
|
||||
+ call_execve(FILENAME, efault, NULL);
|
||||
+ printf("execve(\"%s\", %p, NULL) = %s\n",
|
||||
+ Q_FILENAME, efault, errstr);
|
||||
|
||||
leave_and_remove_subdir();
|
||||
|
||||
diff --git a/tests-mx32/execve.c b/tests-mx32/execve.c
|
||||
index 2f6ae52..961d284 100644
|
||||
--- a/tests-mx32/execve.c
|
||||
+++ b/tests-mx32/execve.c
|
||||
@@ -12,6 +12,16 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
+static const char *errstr;
|
||||
+
|
||||
+static int
|
||||
+call_execve(const char *pathname, char *const *argv, char *const *envp)
|
||||
+{
|
||||
+ int rc = execve(pathname, argv, envp);
|
||||
+ errstr = sprintrc(rc);
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
#define FILENAME "test.execve\nfilename"
|
||||
#define Q_FILENAME "test.execve\\nfilename"
|
||||
|
||||
@@ -43,7 +53,7 @@ main(void)
|
||||
char ** const tail_argv = tail_memdup(argv, sizeof(argv));
|
||||
char ** const tail_envp = tail_memdup(envp, sizeof(envp));
|
||||
|
||||
- execve(FILENAME, tail_argv, tail_envp);
|
||||
+ call_execve(FILENAME, tail_argv, tail_envp);
|
||||
printf("execve(\"%s\""
|
||||
", [\"%s\", \"%s\", \"%s\", %p, %p, %p, ... /* %p */]"
|
||||
#if VERBOSE
|
||||
@@ -51,7 +61,7 @@ main(void)
|
||||
#else
|
||||
", %p /* 5 vars, unterminated */"
|
||||
#endif
|
||||
- ") = -1 ENOENT (%m)\n",
|
||||
+ ") = %s\n",
|
||||
Q_FILENAME, q_argv[0], q_argv[1], q_argv[2],
|
||||
argv[3], argv[4], argv[5], (char *) tail_argv + sizeof(argv)
|
||||
#if VERBOSE
|
||||
@@ -60,60 +70,60 @@ main(void)
|
||||
#else
|
||||
, tail_envp
|
||||
#endif
|
||||
- );
|
||||
+ , errstr);
|
||||
|
||||
tail_argv[ARRAY_SIZE(q_argv)] = NULL;
|
||||
tail_envp[ARRAY_SIZE(q_envp)] = NULL;
|
||||
(void) q_envp; /* workaround for clang bug #33068 */
|
||||
|
||||
- execve(FILENAME, tail_argv, tail_envp);
|
||||
+ call_execve(FILENAME, tail_argv, tail_envp);
|
||||
printf("execve(\"%s\", [\"%s\", \"%s\", \"%s\"]"
|
||||
#if VERBOSE
|
||||
", [\"%s\", \"%s\"]"
|
||||
#else
|
||||
", %p /* 2 vars */"
|
||||
#endif
|
||||
- ") = -1 ENOENT (%m)\n",
|
||||
+ ") = %s\n",
|
||||
Q_FILENAME, q_argv[0], q_argv[1], q_argv[2]
|
||||
#if VERBOSE
|
||||
, q_envp[0], q_envp[1]
|
||||
#else
|
||||
, tail_envp
|
||||
#endif
|
||||
- );
|
||||
+ , errstr);
|
||||
|
||||
- execve(FILENAME, tail_argv + 2, tail_envp + 1);
|
||||
+ call_execve(FILENAME, tail_argv + 2, tail_envp + 1);
|
||||
printf("execve(\"%s\", [\"%s\"]"
|
||||
#if VERBOSE
|
||||
", [\"%s\"]"
|
||||
#else
|
||||
", %p /* 1 var */"
|
||||
#endif
|
||||
- ") = -1 ENOENT (%m)\n",
|
||||
+ ") = %s\n",
|
||||
Q_FILENAME, q_argv[2]
|
||||
#if VERBOSE
|
||||
, q_envp[1]
|
||||
#else
|
||||
, tail_envp + 1
|
||||
#endif
|
||||
- );
|
||||
+ , errstr);
|
||||
|
||||
TAIL_ALLOC_OBJECT_CONST_PTR(char *, empty);
|
||||
char **const efault = empty + 1;
|
||||
*empty = NULL;
|
||||
|
||||
- execve(FILENAME, empty, empty);
|
||||
+ call_execve(FILENAME, empty, empty);
|
||||
printf("execve(\"%s\", []"
|
||||
#if VERBOSE
|
||||
", []"
|
||||
#else
|
||||
", %p /* 0 vars */"
|
||||
#endif
|
||||
- ") = -1 ENOENT (%m)\n", Q_FILENAME
|
||||
+ ") = %s\n", Q_FILENAME
|
||||
#if !VERBOSE
|
||||
, empty
|
||||
#endif
|
||||
- );
|
||||
+ , errstr);
|
||||
|
||||
char *const str_a = tail_alloc(DEFAULT_STRLEN + 2);
|
||||
fill_memory_ex(str_a, DEFAULT_STRLEN + 1, '0', 10);
|
||||
@@ -132,7 +142,7 @@ main(void)
|
||||
}
|
||||
a[i] = b[i] = NULL;
|
||||
|
||||
- execve(FILENAME, a, b);
|
||||
+ call_execve(FILENAME, a, b);
|
||||
printf("execve(\"%s\", [\"%.*s\"...", Q_FILENAME, DEFAULT_STRLEN, a[0]);
|
||||
for (i = 1; i < DEFAULT_STRLEN; ++i)
|
||||
printf(", \"%s\"", a[i]);
|
||||
@@ -149,9 +159,9 @@ main(void)
|
||||
#else
|
||||
printf("], %p /* %u vars */", b, DEFAULT_STRLEN + 1);
|
||||
#endif
|
||||
- printf(") = -1 ENOENT (%m)\n");
|
||||
+ printf(") = %s\n", errstr);
|
||||
|
||||
- execve(FILENAME, a + 1, b + 1);
|
||||
+ call_execve(FILENAME, a + 1, b + 1);
|
||||
printf("execve(\"%s\", [\"%s\"", Q_FILENAME, a[1]);
|
||||
for (i = 2; i <= DEFAULT_STRLEN; ++i)
|
||||
printf(", \"%s\"", a[i]);
|
||||
@@ -163,15 +173,15 @@ main(void)
|
||||
#else
|
||||
printf("], %p /* %d vars */", b + 1, DEFAULT_STRLEN);
|
||||
#endif
|
||||
- printf(") = -1 ENOENT (%m)\n");
|
||||
+ printf(") = %s\n", errstr);
|
||||
|
||||
- execve(FILENAME, (char **) tail_argv[ARRAY_SIZE(q_argv)], efault);
|
||||
- printf("execve(\"%s\", NULL, %p) = -1 ENOENT (%m)\n",
|
||||
- Q_FILENAME, efault);
|
||||
+ call_execve(FILENAME, (char **) tail_argv[ARRAY_SIZE(q_argv)], efault);
|
||||
+ printf("execve(\"%s\", NULL, %p) = %s\n",
|
||||
+ Q_FILENAME, efault, errstr);
|
||||
|
||||
- execve(FILENAME, efault, NULL);
|
||||
- printf("execve(\"%s\", %p, NULL) = -1 ENOENT (%m)\n",
|
||||
- Q_FILENAME, efault);
|
||||
+ call_execve(FILENAME, efault, NULL);
|
||||
+ printf("execve(\"%s\", %p, NULL) = %s\n",
|
||||
+ Q_FILENAME, efault, errstr);
|
||||
|
||||
leave_and_remove_subdir();
|
||||
|
||||
--
|
||||
2.1.4
|
||||
|
13901
SOURCES/0149-Implement-secontext-full-option-to-display-SELinux-c.patch
Normal file
13901
SOURCES/0149-Implement-secontext-full-option-to-display-SELinux-c.patch
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,86 @@
|
||||
From bbe5eefaa928449de5994c5288a7c85fae54f716 Mon Sep 17 00:00:00 2001
|
||||
From: Eugene Syromyatnikov <evgsyr@gmail.com>
|
||||
Date: Sat, 31 Jul 2021 15:17:41 +0200
|
||||
Subject: [PATCH] m4/mpers.m4: generate HAVE_*_SELINUX_RUNTIME config defines
|
||||
|
||||
While bootstrap has some provisions for mangling HAVE_SELINUX_RUNTIME
|
||||
into HAVE_{M32,MX32}_SELINUX_RUNTIME, and there is logic for checking
|
||||
SELinux runtime presence in non-native personalities, the relevant
|
||||
configuration definition is not ultimately generated, as it has to be
|
||||
defined explicitly, similarly to HAVE_*_MPERS.
|
||||
|
||||
* m4/mpers.m4 (st_MPERS) [$st_cv_selinux_runtime == yes]: AC_DEFINE
|
||||
HAVE_SELINUX_RUNTIME.
|
||||
|
||||
Complements: v5.12~49 "Implement --secontext[=full] option to display SELinux contexts"
|
||||
---
|
||||
m4/mpers.m4 | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
Index: strace-5.7/m4/mpers.m4
|
||||
===================================================================
|
||||
--- strace-5.7.orig/m4/mpers.m4 2021-08-24 21:08:43.252246052 +0200
|
||||
+++ strace-5.7/m4/mpers.m4 2021-08-24 21:26:07.436408149 +0200
|
||||
@@ -179,6 +179,10 @@
|
||||
popdef([SIZEOF_STRUCT_MSQID64_DS])
|
||||
fi
|
||||
fi
|
||||
+ if test "x$st_cv_selinux_runtime" = xyes; then
|
||||
+ AC_DEFINE([HAVE_SELINUX_RUNTIME], [1],
|
||||
+ [Define to enable SELinux security contexts testing for ]mpers_name[ personality])
|
||||
+ fi
|
||||
fi
|
||||
CPPFLAGS="$saved_CPPFLAGS"
|
||||
CFLAGS="$saved_CFLAGS"
|
||||
Index: strace-5.7/config.h.in
|
||||
===================================================================
|
||||
--- strace-5.7.orig/config.h.in 2021-08-24 21:08:43.304245612 +0200
|
||||
+++ strace-5.7/config.h.in 2021-08-24 21:26:07.437408141 +0200
|
||||
@@ -2181,6 +2181,9 @@
|
||||
/* Define to 1 if you have mpers_name mpers support */
|
||||
#undef HAVE_M32_MPERS
|
||||
|
||||
+/* Define to enable SELinux security contexts testing for m32 personality */
|
||||
+#undef HAVE_M32_SELINUX_RUNTIME
|
||||
+
|
||||
/* Define to 1 if m32 has the type 'struct stat'. */
|
||||
#undef HAVE_M32_STRUCT_STAT
|
||||
|
||||
@@ -2202,6 +2205,9 @@
|
||||
/* Define to 1 if you have mpers_name mpers support */
|
||||
#undef HAVE_MX32_MPERS
|
||||
|
||||
+/* Define to enable SELinux security contexts testing for mx32 personality */
|
||||
+#undef HAVE_MX32_SELINUX_RUNTIME
|
||||
+
|
||||
/* Define to 1 if mx32 has the type 'struct stat'. */
|
||||
#undef HAVE_MX32_STRUCT_STAT
|
||||
|
||||
Index: strace-5.7/configure
|
||||
===================================================================
|
||||
--- strace-5.7.orig/configure 2021-08-24 21:08:43.315245519 +0200
|
||||
+++ strace-5.7/configure 2021-08-24 21:26:07.439408124 +0200
|
||||
@@ -23632,6 +23632,11 @@
|
||||
|
||||
fi
|
||||
fi
|
||||
+ if test "x$st_cv_m32_selinux_runtime" = xyes; then
|
||||
+
|
||||
+$as_echo "#define HAVE_M32_SELINUX_RUNTIME 1" >>confdefs.h
|
||||
+
|
||||
+ fi
|
||||
fi
|
||||
CPPFLAGS="$saved_CPPFLAGS"
|
||||
CFLAGS="$saved_CFLAGS"
|
||||
@@ -24314,6 +24319,11 @@
|
||||
|
||||
fi
|
||||
fi
|
||||
+ if test "x$st_cv_mx32_selinux_runtime" = xyes; then
|
||||
+
|
||||
+$as_echo "#define HAVE_MX32_SELINUX_RUNTIME 1" >>confdefs.h
|
||||
+
|
||||
+ fi
|
||||
fi
|
||||
CPPFLAGS="$saved_CPPFLAGS"
|
||||
CFLAGS="$saved_CFLAGS"
|
@ -0,0 +1,209 @@
|
||||
From 21bbf3a53b8be9b3fe90bcdb66c7ded35bc3e344 Mon Sep 17 00:00:00 2001
|
||||
From: "Dmitry V. Levin" <ldv@altlinux.org>
|
||||
Date: Sat, 12 Sep 2020 08:00:00 +0000
|
||||
Subject: [PATCH 156/162] Introduce GLIBC_PREREQ_GE and GLIBC_PREREQ_LT macros
|
||||
|
||||
* gcc_compat.h (GLIBC_PREREQ_GE, GLIBC_PREREQ_LT): New macros.
|
||||
* tests/ipc_msg.c: Use GLIBC_PREREQ_LT instead of manual checking
|
||||
for __GLIBC__ and __GLIBC_MINOR__.
|
||||
* tests/readahead.c: Likewise.
|
||||
---
|
||||
gcc_compat.h | 15 +++++++++++++++
|
||||
tests/ipc_msg.c | 9 +++------
|
||||
tests/readahead.c | 16 ++++++----------
|
||||
3 files changed, 24 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/gcc_compat.h b/gcc_compat.h
|
||||
index 0525b5e..4c23ebc 100644
|
||||
--- a/gcc_compat.h
|
||||
+++ b/gcc_compat.h
|
||||
@@ -23,6 +23,21 @@
|
||||
# define CLANG_PREREQ(maj, min) 0
|
||||
# endif
|
||||
|
||||
+# ifdef __GLIBC__
|
||||
+# ifdef __GLIBC_MINOR__
|
||||
+# define GLIBC_PREREQ_GE(maj, min) \
|
||||
+ ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
|
||||
+# define GLIBC_PREREQ_LT(maj, min) \
|
||||
+ ((__GLIBC__ << 16) + __GLIBC_MINOR__ < ((maj) << 16) + (min))
|
||||
+# else /* !__GLIBC_MINOR__ */
|
||||
+# define GLIBC_PREREQ_GE(maj, min) 0
|
||||
+# define GLIBC_PREREQ_LT(maj, min) 1
|
||||
+# endif
|
||||
+# else /* !__GLIBC__ */
|
||||
+# define GLIBC_PREREQ_GE(maj, min) 0
|
||||
+# define GLIBC_PREREQ_LT(maj, min) 0
|
||||
+# endif
|
||||
+
|
||||
# if !(GNUC_PREREQ(2, 0) || CLANG_PREREQ(1, 0))
|
||||
# define __attribute__(x) /* empty */
|
||||
# endif
|
||||
diff --git a/tests/ipc_msg.c b/tests/ipc_msg.c
|
||||
index 63bdd77..dd0f303 100644
|
||||
--- a/tests/ipc_msg.c
|
||||
+++ b/tests/ipc_msg.c
|
||||
@@ -26,12 +26,9 @@
|
||||
* which led to segmentation fault.
|
||||
*/
|
||||
#undef TEST_MSGCTL_BOGUS_ADDR
|
||||
-#if defined __GLIBC__ && (defined POWERPC64 || defined POWERPC64LE)
|
||||
-# if !(defined __GLIBC_MINOR__) \
|
||||
- || ((__GLIBC__ << 16) + __GLIBC_MINOR__ < (2 << 16) + 23)
|
||||
-# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
-# endif
|
||||
-#endif /* __GLIBC__ && (POWERPC64 || POWERPC64LE) */
|
||||
+#if GLIBC_PREREQ_LT(2, 23) && (defined POWERPC64 || defined POWERPC64LE)
|
||||
+# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
+#endif
|
||||
|
||||
#ifndef TEST_MSGCTL_BOGUS_ADDR
|
||||
# define TEST_MSGCTL_BOGUS_ADDR 1
|
||||
diff --git a/tests/readahead.c b/tests/readahead.c
|
||||
index 86d09b0..6f4b81e 100644
|
||||
--- a/tests/readahead.c
|
||||
+++ b/tests/readahead.c
|
||||
@@ -11,24 +11,20 @@
|
||||
|
||||
#ifdef HAVE_READAHEAD
|
||||
/* Check for glibc readahead argument passing bugs. */
|
||||
-# ifdef __GLIBC__
|
||||
/*
|
||||
* glibc < 2.8 had an incorrect order of higher and lower parts of offset,
|
||||
* see https://sourceware.org/bugzilla/show_bug.cgi?id=5208
|
||||
*/
|
||||
-# if !(defined __GLIBC_MINOR__ && \
|
||||
- (__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 8)
|
||||
-# undef HAVE_READAHEAD
|
||||
-# endif /* glibc < 2.8 */
|
||||
+# if GLIBC_PREREQ_LT(2, 8)
|
||||
+# undef HAVE_READAHEAD
|
||||
+# endif /* glibc < 2.8 */
|
||||
/*
|
||||
* glibc < 2.25 had an incorrect implementation on mips n64,
|
||||
* see https://sourceware.org/bugzilla/show_bug.cgi?id=21026
|
||||
*/
|
||||
-# if defined LINUX_MIPSN64 && !(defined __GLIBC_MINOR__ && \
|
||||
- (__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 25)
|
||||
-# undef HAVE_READAHEAD
|
||||
-# endif /* LINUX_MIPSN64 && glibc < 2.25 */
|
||||
-# endif /* __GLIBC__ */
|
||||
+# if GLIBC_PREREQ_LT(2, 25) && defined LINUX_MIPSN64
|
||||
+# undef HAVE_READAHEAD
|
||||
+# endif /* LINUX_MIPSN64 && glibc < 2.25 */
|
||||
#endif /* HAVE_READAHEAD */
|
||||
|
||||
#ifdef HAVE_READAHEAD
|
||||
diff --git a/tests-m32/ipc_msg.c b/tests-m32/ipc_msg.c
|
||||
index 63bdd77..dd0f303 100644
|
||||
--- a/tests-m32/ipc_msg.c
|
||||
+++ b/tests-m32/ipc_msg.c
|
||||
@@ -26,12 +26,9 @@
|
||||
* which led to segmentation fault.
|
||||
*/
|
||||
#undef TEST_MSGCTL_BOGUS_ADDR
|
||||
-#if defined __GLIBC__ && (defined POWERPC64 || defined POWERPC64LE)
|
||||
-# if !(defined __GLIBC_MINOR__) \
|
||||
- || ((__GLIBC__ << 16) + __GLIBC_MINOR__ < (2 << 16) + 23)
|
||||
-# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
-# endif
|
||||
-#endif /* __GLIBC__ && (POWERPC64 || POWERPC64LE) */
|
||||
+#if GLIBC_PREREQ_LT(2, 23) && (defined POWERPC64 || defined POWERPC64LE)
|
||||
+# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
+#endif
|
||||
|
||||
#ifndef TEST_MSGCTL_BOGUS_ADDR
|
||||
# define TEST_MSGCTL_BOGUS_ADDR 1
|
||||
diff --git a/tests-m32/readahead.c b/tests-m32/readahead.c
|
||||
index 86d09b0..6f4b81e 100644
|
||||
--- a/tests-m32/readahead.c
|
||||
+++ b/tests-m32/readahead.c
|
||||
@@ -11,24 +11,20 @@
|
||||
|
||||
#ifdef HAVE_READAHEAD
|
||||
/* Check for glibc readahead argument passing bugs. */
|
||||
-# ifdef __GLIBC__
|
||||
/*
|
||||
* glibc < 2.8 had an incorrect order of higher and lower parts of offset,
|
||||
* see https://sourceware.org/bugzilla/show_bug.cgi?id=5208
|
||||
*/
|
||||
-# if !(defined __GLIBC_MINOR__ && \
|
||||
- (__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 8)
|
||||
-# undef HAVE_READAHEAD
|
||||
-# endif /* glibc < 2.8 */
|
||||
+# if GLIBC_PREREQ_LT(2, 8)
|
||||
+# undef HAVE_READAHEAD
|
||||
+# endif /* glibc < 2.8 */
|
||||
/*
|
||||
* glibc < 2.25 had an incorrect implementation on mips n64,
|
||||
* see https://sourceware.org/bugzilla/show_bug.cgi?id=21026
|
||||
*/
|
||||
-# if defined LINUX_MIPSN64 && !(defined __GLIBC_MINOR__ && \
|
||||
- (__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 25)
|
||||
-# undef HAVE_READAHEAD
|
||||
-# endif /* LINUX_MIPSN64 && glibc < 2.25 */
|
||||
-# endif /* __GLIBC__ */
|
||||
+# if GLIBC_PREREQ_LT(2, 25) && defined LINUX_MIPSN64
|
||||
+# undef HAVE_READAHEAD
|
||||
+# endif /* LINUX_MIPSN64 && glibc < 2.25 */
|
||||
#endif /* HAVE_READAHEAD */
|
||||
|
||||
#ifdef HAVE_READAHEAD
|
||||
diff --git a/tests-mx32/ipc_msg.c b/tests-mx32/ipc_msg.c
|
||||
index 63bdd77..dd0f303 100644
|
||||
--- a/tests-mx32/ipc_msg.c
|
||||
+++ b/tests-mx32/ipc_msg.c
|
||||
@@ -26,12 +26,9 @@
|
||||
* which led to segmentation fault.
|
||||
*/
|
||||
#undef TEST_MSGCTL_BOGUS_ADDR
|
||||
-#if defined __GLIBC__ && (defined POWERPC64 || defined POWERPC64LE)
|
||||
-# if !(defined __GLIBC_MINOR__) \
|
||||
- || ((__GLIBC__ << 16) + __GLIBC_MINOR__ < (2 << 16) + 23)
|
||||
-# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
-# endif
|
||||
-#endif /* __GLIBC__ && (POWERPC64 || POWERPC64LE) */
|
||||
+#if GLIBC_PREREQ_LT(2, 23) && (defined POWERPC64 || defined POWERPC64LE)
|
||||
+# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
+#endif
|
||||
|
||||
#ifndef TEST_MSGCTL_BOGUS_ADDR
|
||||
# define TEST_MSGCTL_BOGUS_ADDR 1
|
||||
diff --git a/tests-mx32/readahead.c b/tests-mx32/readahead.c
|
||||
index 86d09b0..6f4b81e 100644
|
||||
--- a/tests-mx32/readahead.c
|
||||
+++ b/tests-mx32/readahead.c
|
||||
@@ -11,24 +11,20 @@
|
||||
|
||||
#ifdef HAVE_READAHEAD
|
||||
/* Check for glibc readahead argument passing bugs. */
|
||||
-# ifdef __GLIBC__
|
||||
/*
|
||||
* glibc < 2.8 had an incorrect order of higher and lower parts of offset,
|
||||
* see https://sourceware.org/bugzilla/show_bug.cgi?id=5208
|
||||
*/
|
||||
-# if !(defined __GLIBC_MINOR__ && \
|
||||
- (__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 8)
|
||||
-# undef HAVE_READAHEAD
|
||||
-# endif /* glibc < 2.8 */
|
||||
+# if GLIBC_PREREQ_LT(2, 8)
|
||||
+# undef HAVE_READAHEAD
|
||||
+# endif /* glibc < 2.8 */
|
||||
/*
|
||||
* glibc < 2.25 had an incorrect implementation on mips n64,
|
||||
* see https://sourceware.org/bugzilla/show_bug.cgi?id=21026
|
||||
*/
|
||||
-# if defined LINUX_MIPSN64 && !(defined __GLIBC_MINOR__ && \
|
||||
- (__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 25)
|
||||
-# undef HAVE_READAHEAD
|
||||
-# endif /* LINUX_MIPSN64 && glibc < 2.25 */
|
||||
-# endif /* __GLIBC__ */
|
||||
+# if GLIBC_PREREQ_LT(2, 25) && defined LINUX_MIPSN64
|
||||
+# undef HAVE_READAHEAD
|
||||
+# endif /* LINUX_MIPSN64 && glibc < 2.25 */
|
||||
#endif /* HAVE_READAHEAD */
|
||||
|
||||
#ifdef HAVE_READAHEAD
|
||||
--
|
||||
2.1.4
|
||||
|
@ -0,0 +1,103 @@
|
||||
From af1e2888699afc985d7f354b875c517531dff4ea Mon Sep 17 00:00:00 2001
|
||||
From: "Dmitry V. Levin" <ldv@altlinux.org>
|
||||
Date: Sat, 12 Sep 2020 08:00:00 +0000
|
||||
Subject: [PATCH 157/162] tests/ipc_msg.c: disable TEST_MSGCTL_BOGUS_ADDR on
|
||||
glibc >= 2.32
|
||||
|
||||
Starting with commit glibc-2.32~83, on every 32-bit architecture where
|
||||
32-bit time_t support is enabled, glibc tries to retrieve the data
|
||||
provided in the third argument of msgctl call. This results to
|
||||
segfaults inside glibc if TEST_MSGCTL_BOGUS_ADDR is enabled.
|
||||
|
||||
* tests/ipc_msg.c [GLIBC_PREREQ_GE(2, 32) && __TIMESIZE != 64]
|
||||
(TEST_MSGCTL_BOGUS_ADDR): Define to 0.
|
||||
|
||||
Reported-by: Ruinland ChuanTzu Tsai <ruinland@andestech.com>
|
||||
---
|
||||
tests/ipc_msg.c | 11 ++++++++++-
|
||||
1 file changed, 10 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tests/ipc_msg.c b/tests/ipc_msg.c
|
||||
index dd0f303..3ab8b90 100644
|
||||
--- a/tests/ipc_msg.c
|
||||
+++ b/tests/ipc_msg.c
|
||||
@@ -20,12 +20,21 @@
|
||||
# define MSG_STAT_ANY 13
|
||||
#endif
|
||||
|
||||
+#undef TEST_MSGCTL_BOGUS_ADDR
|
||||
+
|
||||
+/*
|
||||
+ * Starting with commit glibc-2.32~83, on every 32-bit architecture
|
||||
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
|
||||
+ * the data provided in the third argument of msgctl call.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
|
||||
+# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
+#endif
|
||||
/*
|
||||
* Before glibc-2.22-122-gbe48165, ppc64 code tried to retrieve data
|
||||
* provided in third argument of msgctl call (in case of IPC_SET cmd)
|
||||
* which led to segmentation fault.
|
||||
*/
|
||||
-#undef TEST_MSGCTL_BOGUS_ADDR
|
||||
#if GLIBC_PREREQ_LT(2, 23) && (defined POWERPC64 || defined POWERPC64LE)
|
||||
# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
#endif
|
||||
diff --git a/tests-m32/ipc_msg.c b/tests-m32/ipc_msg.c
|
||||
index dd0f303..3ab8b90 100644
|
||||
--- a/tests-m32/ipc_msg.c
|
||||
+++ b/tests-m32/ipc_msg.c
|
||||
@@ -20,12 +20,21 @@
|
||||
# define MSG_STAT_ANY 13
|
||||
#endif
|
||||
|
||||
+#undef TEST_MSGCTL_BOGUS_ADDR
|
||||
+
|
||||
+/*
|
||||
+ * Starting with commit glibc-2.32~83, on every 32-bit architecture
|
||||
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
|
||||
+ * the data provided in the third argument of msgctl call.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
|
||||
+# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
+#endif
|
||||
/*
|
||||
* Before glibc-2.22-122-gbe48165, ppc64 code tried to retrieve data
|
||||
* provided in third argument of msgctl call (in case of IPC_SET cmd)
|
||||
* which led to segmentation fault.
|
||||
*/
|
||||
-#undef TEST_MSGCTL_BOGUS_ADDR
|
||||
#if GLIBC_PREREQ_LT(2, 23) && (defined POWERPC64 || defined POWERPC64LE)
|
||||
# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
#endif
|
||||
diff --git a/tests-mx32/ipc_msg.c b/tests-mx32/ipc_msg.c
|
||||
index dd0f303..3ab8b90 100644
|
||||
--- a/tests-mx32/ipc_msg.c
|
||||
+++ b/tests-mx32/ipc_msg.c
|
||||
@@ -20,12 +20,21 @@
|
||||
# define MSG_STAT_ANY 13
|
||||
#endif
|
||||
|
||||
+#undef TEST_MSGCTL_BOGUS_ADDR
|
||||
+
|
||||
+/*
|
||||
+ * Starting with commit glibc-2.32~83, on every 32-bit architecture
|
||||
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
|
||||
+ * the data provided in the third argument of msgctl call.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
|
||||
+# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
+#endif
|
||||
/*
|
||||
* Before glibc-2.22-122-gbe48165, ppc64 code tried to retrieve data
|
||||
* provided in third argument of msgctl call (in case of IPC_SET cmd)
|
||||
* which led to segmentation fault.
|
||||
*/
|
||||
-#undef TEST_MSGCTL_BOGUS_ADDR
|
||||
#if GLIBC_PREREQ_LT(2, 23) && (defined POWERPC64 || defined POWERPC64LE)
|
||||
# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
#endif
|
||||
--
|
||||
2.1.4
|
||||
|
@ -0,0 +1,89 @@
|
||||
From b4623939316807928680913ece9a6cefc23a73b2 Mon Sep 17 00:00:00 2001
|
||||
From: "Dmitry V. Levin" <ldv@altlinux.org>
|
||||
Date: Tue, 10 Nov 2020 08:00:00 +0000
|
||||
Subject: [PATCH 158/162] tests: disable TEST_MSGCTL_BOGUS_ADDR in ipc_msg test
|
||||
on glibc >= 2.31
|
||||
|
||||
Starting with commit glibc-2.31~358, on every architecture where
|
||||
__ASSUME_SYSVIPC_BROKEN_MODE_T is defined, glibc tries to modify the
|
||||
data provided in the third argument of msgctl call. This results
|
||||
to segfaults inside glibc if TEST_MSGCTL_BOGUS_ADDR is enabled.
|
||||
|
||||
* tests/ipc_msg.c [GLIBC_PREREQ_GE(2, 31) && (__m68k__ || __s390__ ||
|
||||
(WORDS_BIGENDIAN && (__arm__ || __microblaze__ || __sh__)))]
|
||||
(TEST_MSGCTL_BOGUS_ADDR): Define to 0.
|
||||
|
||||
Reported-by: Sven Schnelle <svens@linux.ibm.com>
|
||||
---
|
||||
tests/ipc_msg.c | 11 +++++++++++
|
||||
1 file changed, 11 insertions(+)
|
||||
|
||||
diff --git a/tests/ipc_msg.c b/tests/ipc_msg.c
|
||||
index 3ab8b90..f7c36cd 100644
|
||||
--- a/tests/ipc_msg.c
|
||||
+++ b/tests/ipc_msg.c
|
||||
@@ -31,6 +31,17 @@
|
||||
# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
#endif
|
||||
/*
|
||||
+ * Starting with commit glibc-2.31~358, on every architecture where
|
||||
+ * __ASSUME_SYSVIPC_BROKEN_MODE_T is defined, glibc tries to modify
|
||||
+ * the data provided in the third argument of msgctl call.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 31) && \
|
||||
+ (defined __m68k__ || defined __s390__ || \
|
||||
+ (WORDS_BIGENDIAN && \
|
||||
+ (defined __arm__ || defined __microblaze__ || defined __sh__)))
|
||||
+# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
+#endif
|
||||
+/*
|
||||
* Before glibc-2.22-122-gbe48165, ppc64 code tried to retrieve data
|
||||
* provided in third argument of msgctl call (in case of IPC_SET cmd)
|
||||
* which led to segmentation fault.
|
||||
diff --git a/tests-m32/ipc_msg.c b/tests-m32/ipc_msg.c
|
||||
index 3ab8b90..f7c36cd 100644
|
||||
--- a/tests-m32/ipc_msg.c
|
||||
+++ b/tests-m32/ipc_msg.c
|
||||
@@ -31,6 +31,17 @@
|
||||
# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
#endif
|
||||
/*
|
||||
+ * Starting with commit glibc-2.31~358, on every architecture where
|
||||
+ * __ASSUME_SYSVIPC_BROKEN_MODE_T is defined, glibc tries to modify
|
||||
+ * the data provided in the third argument of msgctl call.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 31) && \
|
||||
+ (defined __m68k__ || defined __s390__ || \
|
||||
+ (WORDS_BIGENDIAN && \
|
||||
+ (defined __arm__ || defined __microblaze__ || defined __sh__)))
|
||||
+# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
+#endif
|
||||
+/*
|
||||
* Before glibc-2.22-122-gbe48165, ppc64 code tried to retrieve data
|
||||
* provided in third argument of msgctl call (in case of IPC_SET cmd)
|
||||
* which led to segmentation fault.
|
||||
diff --git a/tests-mx32/ipc_msg.c b/tests-mx32/ipc_msg.c
|
||||
index 3ab8b90..f7c36cd 100644
|
||||
--- a/tests-mx32/ipc_msg.c
|
||||
+++ b/tests-mx32/ipc_msg.c
|
||||
@@ -31,6 +31,17 @@
|
||||
# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
#endif
|
||||
/*
|
||||
+ * Starting with commit glibc-2.31~358, on every architecture where
|
||||
+ * __ASSUME_SYSVIPC_BROKEN_MODE_T is defined, glibc tries to modify
|
||||
+ * the data provided in the third argument of msgctl call.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 31) && \
|
||||
+ (defined __m68k__ || defined __s390__ || \
|
||||
+ (WORDS_BIGENDIAN && \
|
||||
+ (defined __arm__ || defined __microblaze__ || defined __sh__)))
|
||||
+# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
+#endif
|
||||
+/*
|
||||
* Before glibc-2.22-122-gbe48165, ppc64 code tried to retrieve data
|
||||
* provided in third argument of msgctl call (in case of IPC_SET cmd)
|
||||
* which led to segmentation fault.
|
||||
--
|
||||
2.1.4
|
||||
|
@ -0,0 +1,214 @@
|
||||
From b702ddfd448794f3ac5033c897a07da3de8f5fc7 Mon Sep 17 00:00:00 2001
|
||||
From: "Dmitry V. Levin" <ldv@altlinux.org>
|
||||
Date: Sun, 6 Dec 2020 08:00:00 +0000
|
||||
Subject: [PATCH 159/162] tests: disable tests for invalid msgctl commands on
|
||||
glibc >= 2.32
|
||||
|
||||
Starting with commit glibc-2.32.9000-149-gbe9b0b9a012780a403a2,
|
||||
glibc skips msgctl syscall invocations and returns EINVAL
|
||||
for invalid msgctl commands.
|
||||
|
||||
* tests/ipc_msg.c [GLIBC_PREREQ_GE(2, 32)] (TEST_MSGCTL_BOGUS_CMD):
|
||||
Define to 0.
|
||||
[!TEST_MSGCTL_BOGUS_CMD] (TEST_MSGCTL_BOGUS_CMD): Define to 1.
|
||||
(main) [!TEST_MSGCTL_BOGUS_CMD] (bogus_cmd): Do not define and do not
|
||||
use.
|
||||
---
|
||||
tests/ipc_msg.c | 21 ++++++++++++++++++++-
|
||||
1 file changed, 20 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tests/ipc_msg.c b/tests/ipc_msg.c
|
||||
index f7c36cd..6a96a5f 100644
|
||||
--- a/tests/ipc_msg.c
|
||||
+++ b/tests/ipc_msg.c
|
||||
@@ -21,6 +21,7 @@
|
||||
#endif
|
||||
|
||||
#undef TEST_MSGCTL_BOGUS_ADDR
|
||||
+#undef TEST_MSGCTL_BOGUS_CMD
|
||||
|
||||
/*
|
||||
* Starting with commit glibc-2.32~83, on every 32-bit architecture
|
||||
@@ -50,9 +51,21 @@
|
||||
# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
#endif
|
||||
|
||||
+/*
|
||||
+ * Starting with commit glibc-2.32.9000-149-gbe9b0b9a012780a403a2,
|
||||
+ * glibc skips msgctl syscall invocations and returns EINVAL
|
||||
+ * for invalid msgctl commands.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 32)
|
||||
+# define TEST_MSGCTL_BOGUS_CMD 0
|
||||
+#endif
|
||||
+
|
||||
#ifndef TEST_MSGCTL_BOGUS_ADDR
|
||||
# define TEST_MSGCTL_BOGUS_ADDR 1
|
||||
#endif
|
||||
+#ifndef TEST_MSGCTL_BOGUS_CMD
|
||||
+# define TEST_MSGCTL_BOGUS_CMD 1
|
||||
+#endif
|
||||
|
||||
#if XLAT_RAW
|
||||
# define str_ipc_excl_nowait "0xface1c00"
|
||||
@@ -107,12 +120,16 @@ main(void)
|
||||
static const key_t private_key =
|
||||
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
|
||||
static const key_t bogus_key = (key_t) 0xeca86420fdb9f531ULL;
|
||||
+ static const int bogus_flags = 0xface1e55 & ~IPC_CREAT;
|
||||
+#if TEST_MSGCTL_BOGUS_CMD || TEST_MSGCTL_BOGUS_ADDR
|
||||
static const int bogus_msgid = 0xfdb97531;
|
||||
+#endif
|
||||
+#if TEST_MSGCTL_BOGUS_CMD
|
||||
static const int bogus_cmd = 0xdeadbeef;
|
||||
+#endif
|
||||
#if TEST_MSGCTL_BOGUS_ADDR
|
||||
static void * const bogus_addr = (void *) -1L;
|
||||
#endif
|
||||
- static const int bogus_flags = 0xface1e55 & ~IPC_CREAT;
|
||||
|
||||
int rc;
|
||||
struct msqid_ds ds;
|
||||
@@ -129,9 +146,11 @@ main(void)
|
||||
printf("msgget\\(%s, 0600\\) = %d\n", str_ipc_private, id);
|
||||
atexit(cleanup);
|
||||
|
||||
+#if TEST_MSGCTL_BOGUS_CMD
|
||||
rc = msgctl(bogus_msgid, bogus_cmd, NULL);
|
||||
printf("msgctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
|
||||
bogus_msgid, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
|
||||
+#endif
|
||||
|
||||
#if TEST_MSGCTL_BOGUS_ADDR
|
||||
rc = msgctl(bogus_msgid, IPC_SET, bogus_addr);
|
||||
diff --git a/tests-m32/ipc_msg.c b/tests-m32/ipc_msg.c
|
||||
index f7c36cd..6a96a5f 100644
|
||||
--- a/tests-m32/ipc_msg.c
|
||||
+++ b/tests-m32/ipc_msg.c
|
||||
@@ -21,6 +21,7 @@
|
||||
#endif
|
||||
|
||||
#undef TEST_MSGCTL_BOGUS_ADDR
|
||||
+#undef TEST_MSGCTL_BOGUS_CMD
|
||||
|
||||
/*
|
||||
* Starting with commit glibc-2.32~83, on every 32-bit architecture
|
||||
@@ -50,9 +51,21 @@
|
||||
# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
#endif
|
||||
|
||||
+/*
|
||||
+ * Starting with commit glibc-2.32.9000-149-gbe9b0b9a012780a403a2,
|
||||
+ * glibc skips msgctl syscall invocations and returns EINVAL
|
||||
+ * for invalid msgctl commands.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 32)
|
||||
+# define TEST_MSGCTL_BOGUS_CMD 0
|
||||
+#endif
|
||||
+
|
||||
#ifndef TEST_MSGCTL_BOGUS_ADDR
|
||||
# define TEST_MSGCTL_BOGUS_ADDR 1
|
||||
#endif
|
||||
+#ifndef TEST_MSGCTL_BOGUS_CMD
|
||||
+# define TEST_MSGCTL_BOGUS_CMD 1
|
||||
+#endif
|
||||
|
||||
#if XLAT_RAW
|
||||
# define str_ipc_excl_nowait "0xface1c00"
|
||||
@@ -107,12 +120,16 @@ main(void)
|
||||
static const key_t private_key =
|
||||
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
|
||||
static const key_t bogus_key = (key_t) 0xeca86420fdb9f531ULL;
|
||||
+ static const int bogus_flags = 0xface1e55 & ~IPC_CREAT;
|
||||
+#if TEST_MSGCTL_BOGUS_CMD || TEST_MSGCTL_BOGUS_ADDR
|
||||
static const int bogus_msgid = 0xfdb97531;
|
||||
+#endif
|
||||
+#if TEST_MSGCTL_BOGUS_CMD
|
||||
static const int bogus_cmd = 0xdeadbeef;
|
||||
+#endif
|
||||
#if TEST_MSGCTL_BOGUS_ADDR
|
||||
static void * const bogus_addr = (void *) -1L;
|
||||
#endif
|
||||
- static const int bogus_flags = 0xface1e55 & ~IPC_CREAT;
|
||||
|
||||
int rc;
|
||||
struct msqid_ds ds;
|
||||
@@ -129,9 +146,11 @@ main(void)
|
||||
printf("msgget\\(%s, 0600\\) = %d\n", str_ipc_private, id);
|
||||
atexit(cleanup);
|
||||
|
||||
+#if TEST_MSGCTL_BOGUS_CMD
|
||||
rc = msgctl(bogus_msgid, bogus_cmd, NULL);
|
||||
printf("msgctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
|
||||
bogus_msgid, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
|
||||
+#endif
|
||||
|
||||
#if TEST_MSGCTL_BOGUS_ADDR
|
||||
rc = msgctl(bogus_msgid, IPC_SET, bogus_addr);
|
||||
diff --git a/tests-mx32/ipc_msg.c b/tests-mx32/ipc_msg.c
|
||||
index f7c36cd..6a96a5f 100644
|
||||
--- a/tests-mx32/ipc_msg.c
|
||||
+++ b/tests-mx32/ipc_msg.c
|
||||
@@ -21,6 +21,7 @@
|
||||
#endif
|
||||
|
||||
#undef TEST_MSGCTL_BOGUS_ADDR
|
||||
+#undef TEST_MSGCTL_BOGUS_CMD
|
||||
|
||||
/*
|
||||
* Starting with commit glibc-2.32~83, on every 32-bit architecture
|
||||
@@ -50,9 +51,21 @@
|
||||
# define TEST_MSGCTL_BOGUS_ADDR 0
|
||||
#endif
|
||||
|
||||
+/*
|
||||
+ * Starting with commit glibc-2.32.9000-149-gbe9b0b9a012780a403a2,
|
||||
+ * glibc skips msgctl syscall invocations and returns EINVAL
|
||||
+ * for invalid msgctl commands.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 32)
|
||||
+# define TEST_MSGCTL_BOGUS_CMD 0
|
||||
+#endif
|
||||
+
|
||||
#ifndef TEST_MSGCTL_BOGUS_ADDR
|
||||
# define TEST_MSGCTL_BOGUS_ADDR 1
|
||||
#endif
|
||||
+#ifndef TEST_MSGCTL_BOGUS_CMD
|
||||
+# define TEST_MSGCTL_BOGUS_CMD 1
|
||||
+#endif
|
||||
|
||||
#if XLAT_RAW
|
||||
# define str_ipc_excl_nowait "0xface1c00"
|
||||
@@ -107,12 +120,16 @@ main(void)
|
||||
static const key_t private_key =
|
||||
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
|
||||
static const key_t bogus_key = (key_t) 0xeca86420fdb9f531ULL;
|
||||
+ static const int bogus_flags = 0xface1e55 & ~IPC_CREAT;
|
||||
+#if TEST_MSGCTL_BOGUS_CMD || TEST_MSGCTL_BOGUS_ADDR
|
||||
static const int bogus_msgid = 0xfdb97531;
|
||||
+#endif
|
||||
+#if TEST_MSGCTL_BOGUS_CMD
|
||||
static const int bogus_cmd = 0xdeadbeef;
|
||||
+#endif
|
||||
#if TEST_MSGCTL_BOGUS_ADDR
|
||||
static void * const bogus_addr = (void *) -1L;
|
||||
#endif
|
||||
- static const int bogus_flags = 0xface1e55 & ~IPC_CREAT;
|
||||
|
||||
int rc;
|
||||
struct msqid_ds ds;
|
||||
@@ -129,9 +146,11 @@ main(void)
|
||||
printf("msgget\\(%s, 0600\\) = %d\n", str_ipc_private, id);
|
||||
atexit(cleanup);
|
||||
|
||||
+#if TEST_MSGCTL_BOGUS_CMD
|
||||
rc = msgctl(bogus_msgid, bogus_cmd, NULL);
|
||||
printf("msgctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
|
||||
bogus_msgid, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
|
||||
+#endif
|
||||
|
||||
#if TEST_MSGCTL_BOGUS_ADDR
|
||||
rc = msgctl(bogus_msgid, IPC_SET, bogus_addr);
|
||||
--
|
||||
2.1.4
|
||||
|
@ -0,0 +1,169 @@
|
||||
From 8c1a84778bb05a3becc493698b215681bf7249b3 Mon Sep 17 00:00:00 2001
|
||||
From: "Dmitry V. Levin" <ldv@altlinux.org>
|
||||
Date: Sat, 19 Sep 2020 08:00:00 +0000
|
||||
Subject: [PATCH 160/162] tests: disable shmctl IPC_STAT test with a bogus
|
||||
address on glibc >= 2.32
|
||||
|
||||
Starting with commit glibc-2.32~80, on every 32-bit architecture where
|
||||
32-bit time_t support is enabled, glibc tries to retrieve the data
|
||||
provided in the third argument of shmctl call. This results to
|
||||
segfaults inside glibc when shmctl is called with a bogus address.
|
||||
|
||||
* tests/ipc_shm.c [GLIBC_PREREQ_GE(2, 32) && __TIMESIZE != 64]
|
||||
(TEST_SHMCTL_BOGUS_ADDR): Define to 0.
|
||||
(main): Conditionalize on TEST_SHMCTL_BOGUS_ADDR the shmctl IPC_STAT
|
||||
invocation with a bogus address.
|
||||
---
|
||||
tests/ipc_shm.c | 19 +++++++++++++++++++
|
||||
1 file changed, 19 insertions(+)
|
||||
|
||||
diff --git a/tests/ipc_shm.c b/tests/ipc_shm.c
|
||||
index 5cd414e..695fd94 100644
|
||||
--- a/tests/ipc_shm.c
|
||||
+++ b/tests/ipc_shm.c
|
||||
@@ -73,6 +73,21 @@
|
||||
# define str_bogus_cmd "0xdefaced2 /\\* SHM_\\?\\?\\? \\*/"
|
||||
#endif
|
||||
|
||||
+#undef TEST_SHMCTL_BOGUS_ADDR
|
||||
+
|
||||
+/*
|
||||
+ * Starting with commit glibc-2.32~80, on every 32-bit architecture
|
||||
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
|
||||
+ * the data provided in the third argument of shmctl call.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
|
||||
+# define TEST_SHMCTL_BOGUS_ADDR 0
|
||||
+#endif
|
||||
+
|
||||
+#ifndef TEST_SHMCTL_BOGUS_ADDR
|
||||
+# define TEST_SHMCTL_BOGUS_ADDR 1
|
||||
+#endif
|
||||
+
|
||||
static int id = -1;
|
||||
|
||||
static void
|
||||
@@ -92,7 +107,9 @@ main(void)
|
||||
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
|
||||
static const int bogus_id = 0xdefaced1;
|
||||
static const int bogus_cmd = 0xdefaced2;
|
||||
+#if TEST_SHMCTL_BOGUS_ADDR
|
||||
static void * const bogus_addr = (void *) -1L;
|
||||
+#endif
|
||||
static const size_t bogus_size =
|
||||
/*
|
||||
* musl sets size to SIZE_MAX if size argument is greater than
|
||||
@@ -160,10 +177,12 @@ main(void)
|
||||
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
|
||||
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
|
||||
|
||||
+#if TEST_SHMCTL_BOGUS_ADDR
|
||||
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
|
||||
printf("shmctl\\(%d, (%s\\|)?%s, %p\\) = %s\n",
|
||||
bogus_id, str_ipc_64, str_ipc_stat, bogus_addr,
|
||||
sprintrc_grep(rc));
|
||||
+#endif
|
||||
|
||||
if (shmctl(id, IPC_STAT, &ds))
|
||||
perror_msg_and_skip("shmctl IPC_STAT");
|
||||
diff --git a/tests-m32/ipc_shm.c b/tests-m32/ipc_shm.c
|
||||
index 5cd414e..695fd94 100644
|
||||
--- a/tests-m32/ipc_shm.c
|
||||
+++ b/tests-m32/ipc_shm.c
|
||||
@@ -73,6 +73,21 @@
|
||||
# define str_bogus_cmd "0xdefaced2 /\\* SHM_\\?\\?\\? \\*/"
|
||||
#endif
|
||||
|
||||
+#undef TEST_SHMCTL_BOGUS_ADDR
|
||||
+
|
||||
+/*
|
||||
+ * Starting with commit glibc-2.32~80, on every 32-bit architecture
|
||||
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
|
||||
+ * the data provided in the third argument of shmctl call.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
|
||||
+# define TEST_SHMCTL_BOGUS_ADDR 0
|
||||
+#endif
|
||||
+
|
||||
+#ifndef TEST_SHMCTL_BOGUS_ADDR
|
||||
+# define TEST_SHMCTL_BOGUS_ADDR 1
|
||||
+#endif
|
||||
+
|
||||
static int id = -1;
|
||||
|
||||
static void
|
||||
@@ -92,7 +107,9 @@ main(void)
|
||||
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
|
||||
static const int bogus_id = 0xdefaced1;
|
||||
static const int bogus_cmd = 0xdefaced2;
|
||||
+#if TEST_SHMCTL_BOGUS_ADDR
|
||||
static void * const bogus_addr = (void *) -1L;
|
||||
+#endif
|
||||
static const size_t bogus_size =
|
||||
/*
|
||||
* musl sets size to SIZE_MAX if size argument is greater than
|
||||
@@ -160,10 +177,12 @@ main(void)
|
||||
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
|
||||
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
|
||||
|
||||
+#if TEST_SHMCTL_BOGUS_ADDR
|
||||
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
|
||||
printf("shmctl\\(%d, (%s\\|)?%s, %p\\) = %s\n",
|
||||
bogus_id, str_ipc_64, str_ipc_stat, bogus_addr,
|
||||
sprintrc_grep(rc));
|
||||
+#endif
|
||||
|
||||
if (shmctl(id, IPC_STAT, &ds))
|
||||
perror_msg_and_skip("shmctl IPC_STAT");
|
||||
diff --git a/tests-mx32/ipc_shm.c b/tests-mx32/ipc_shm.c
|
||||
index 5cd414e..695fd94 100644
|
||||
--- a/tests-mx32/ipc_shm.c
|
||||
+++ b/tests-mx32/ipc_shm.c
|
||||
@@ -73,6 +73,21 @@
|
||||
# define str_bogus_cmd "0xdefaced2 /\\* SHM_\\?\\?\\? \\*/"
|
||||
#endif
|
||||
|
||||
+#undef TEST_SHMCTL_BOGUS_ADDR
|
||||
+
|
||||
+/*
|
||||
+ * Starting with commit glibc-2.32~80, on every 32-bit architecture
|
||||
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
|
||||
+ * the data provided in the third argument of shmctl call.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
|
||||
+# define TEST_SHMCTL_BOGUS_ADDR 0
|
||||
+#endif
|
||||
+
|
||||
+#ifndef TEST_SHMCTL_BOGUS_ADDR
|
||||
+# define TEST_SHMCTL_BOGUS_ADDR 1
|
||||
+#endif
|
||||
+
|
||||
static int id = -1;
|
||||
|
||||
static void
|
||||
@@ -92,7 +107,9 @@ main(void)
|
||||
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
|
||||
static const int bogus_id = 0xdefaced1;
|
||||
static const int bogus_cmd = 0xdefaced2;
|
||||
+#if TEST_SHMCTL_BOGUS_ADDR
|
||||
static void * const bogus_addr = (void *) -1L;
|
||||
+#endif
|
||||
static const size_t bogus_size =
|
||||
/*
|
||||
* musl sets size to SIZE_MAX if size argument is greater than
|
||||
@@ -160,10 +177,12 @@ main(void)
|
||||
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
|
||||
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
|
||||
|
||||
+#if TEST_SHMCTL_BOGUS_ADDR
|
||||
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
|
||||
printf("shmctl\\(%d, (%s\\|)?%s, %p\\) = %s\n",
|
||||
bogus_id, str_ipc_64, str_ipc_stat, bogus_addr,
|
||||
sprintrc_grep(rc));
|
||||
+#endif
|
||||
|
||||
if (shmctl(id, IPC_STAT, &ds))
|
||||
perror_msg_and_skip("shmctl IPC_STAT");
|
||||
--
|
||||
2.1.4
|
||||
|
@ -0,0 +1,280 @@
|
||||
From 268b9341ef6397cc337f612563af88ccb5752ca7 Mon Sep 17 00:00:00 2001
|
||||
From: "Dmitry V. Levin" <ldv@altlinux.org>
|
||||
Date: Sun, 6 Dec 2020 08:00:00 +0000
|
||||
Subject: [PATCH 161/162] tests: disable tests for invalid shmctl commands on
|
||||
glibc >= 2.32
|
||||
|
||||
Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
|
||||
glibc skips shmctl syscall invocations and returns EINVAL
|
||||
for invalid shmctl commands.
|
||||
|
||||
* tests/ipc_shm.c [GLIBC_PREREQ_GE(2, 32)] (TEST_SHMCTL_BOGUS_CMD):
|
||||
Define to 0.
|
||||
[!TEST_SHMCTL_BOGUS_CMD] (TEST_SHMCTL_BOGUS_CMD): Define to 1.
|
||||
(main) [!TEST_SHMCTL_BOGUS_CMD] (bogus_cmd): Do not define and do not
|
||||
use.
|
||||
---
|
||||
tests/ipc_shm.c | 49 ++++++++++++++++++++++++++++++++++---------------
|
||||
1 file changed, 34 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/tests/ipc_shm.c b/tests/ipc_shm.c
|
||||
index 695fd94..350bde5 100644
|
||||
--- a/tests/ipc_shm.c
|
||||
+++ b/tests/ipc_shm.c
|
||||
@@ -29,6 +29,34 @@
|
||||
# define SHM_NORESERVE 010000
|
||||
#endif
|
||||
|
||||
+#undef TEST_SHMCTL_BOGUS_ADDR
|
||||
+#undef TEST_SHMCTL_BOGUS_CMD
|
||||
+
|
||||
+/*
|
||||
+ * Starting with commit glibc-2.32~80, on every 32-bit architecture
|
||||
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
|
||||
+ * the data provided in the third argument of shmctl call.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
|
||||
+# define TEST_SHMCTL_BOGUS_ADDR 0
|
||||
+#endif
|
||||
+
|
||||
+/*
|
||||
+ * Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
|
||||
+ * glibc skips shmctl syscall invocations and returns EINVAL
|
||||
+ * for invalid shmctl commands.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 32)
|
||||
+# define TEST_SHMCTL_BOGUS_CMD 0
|
||||
+#endif
|
||||
+
|
||||
+#ifndef TEST_SHMCTL_BOGUS_ADDR
|
||||
+# define TEST_SHMCTL_BOGUS_ADDR 1
|
||||
+#endif
|
||||
+#ifndef TEST_SHMCTL_BOGUS_CMD
|
||||
+# define TEST_SHMCTL_BOGUS_CMD 1
|
||||
+#endif
|
||||
+
|
||||
#include "xlat.h"
|
||||
#include "xlat/shm_resource_flags.h"
|
||||
|
||||
@@ -73,21 +101,6 @@
|
||||
# define str_bogus_cmd "0xdefaced2 /\\* SHM_\\?\\?\\? \\*/"
|
||||
#endif
|
||||
|
||||
-#undef TEST_SHMCTL_BOGUS_ADDR
|
||||
-
|
||||
-/*
|
||||
- * Starting with commit glibc-2.32~80, on every 32-bit architecture
|
||||
- * where 32-bit time_t support is enabled, glibc tries to retrieve
|
||||
- * the data provided in the third argument of shmctl call.
|
||||
- */
|
||||
-#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
|
||||
-# define TEST_SHMCTL_BOGUS_ADDR 0
|
||||
-#endif
|
||||
-
|
||||
-#ifndef TEST_SHMCTL_BOGUS_ADDR
|
||||
-# define TEST_SHMCTL_BOGUS_ADDR 1
|
||||
-#endif
|
||||
-
|
||||
static int id = -1;
|
||||
|
||||
static void
|
||||
@@ -105,8 +118,12 @@ main(void)
|
||||
static const key_t private_key =
|
||||
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
|
||||
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
|
||||
+#if TEST_SHMCTL_BOGUS_CMD || TEST_SHMCTL_BOGUS_ADDR
|
||||
static const int bogus_id = 0xdefaced1;
|
||||
+#endif
|
||||
+#if TEST_SHMCTL_BOGUS_CMD
|
||||
static const int bogus_cmd = 0xdefaced2;
|
||||
+#endif
|
||||
#if TEST_SHMCTL_BOGUS_ADDR
|
||||
static void * const bogus_addr = (void *) -1L;
|
||||
#endif
|
||||
@@ -173,9 +190,11 @@ main(void)
|
||||
printf("shmget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id);
|
||||
atexit(cleanup);
|
||||
|
||||
+#if TEST_SHMCTL_BOGUS_CMD
|
||||
rc = shmctl(bogus_id, bogus_cmd, NULL);
|
||||
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
|
||||
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
|
||||
+#endif
|
||||
|
||||
#if TEST_SHMCTL_BOGUS_ADDR
|
||||
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
|
||||
diff --git a/tests-m32/ipc_shm.c b/tests-m32/ipc_shm.c
|
||||
index 695fd94..350bde5 100644
|
||||
--- a/tests-m32/ipc_shm.c
|
||||
+++ b/tests-m32/ipc_shm.c
|
||||
@@ -29,6 +29,34 @@
|
||||
# define SHM_NORESERVE 010000
|
||||
#endif
|
||||
|
||||
+#undef TEST_SHMCTL_BOGUS_ADDR
|
||||
+#undef TEST_SHMCTL_BOGUS_CMD
|
||||
+
|
||||
+/*
|
||||
+ * Starting with commit glibc-2.32~80, on every 32-bit architecture
|
||||
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
|
||||
+ * the data provided in the third argument of shmctl call.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
|
||||
+# define TEST_SHMCTL_BOGUS_ADDR 0
|
||||
+#endif
|
||||
+
|
||||
+/*
|
||||
+ * Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
|
||||
+ * glibc skips shmctl syscall invocations and returns EINVAL
|
||||
+ * for invalid shmctl commands.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 32)
|
||||
+# define TEST_SHMCTL_BOGUS_CMD 0
|
||||
+#endif
|
||||
+
|
||||
+#ifndef TEST_SHMCTL_BOGUS_ADDR
|
||||
+# define TEST_SHMCTL_BOGUS_ADDR 1
|
||||
+#endif
|
||||
+#ifndef TEST_SHMCTL_BOGUS_CMD
|
||||
+# define TEST_SHMCTL_BOGUS_CMD 1
|
||||
+#endif
|
||||
+
|
||||
#include "xlat.h"
|
||||
#include "xlat/shm_resource_flags.h"
|
||||
|
||||
@@ -73,21 +101,6 @@
|
||||
# define str_bogus_cmd "0xdefaced2 /\\* SHM_\\?\\?\\? \\*/"
|
||||
#endif
|
||||
|
||||
-#undef TEST_SHMCTL_BOGUS_ADDR
|
||||
-
|
||||
-/*
|
||||
- * Starting with commit glibc-2.32~80, on every 32-bit architecture
|
||||
- * where 32-bit time_t support is enabled, glibc tries to retrieve
|
||||
- * the data provided in the third argument of shmctl call.
|
||||
- */
|
||||
-#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
|
||||
-# define TEST_SHMCTL_BOGUS_ADDR 0
|
||||
-#endif
|
||||
-
|
||||
-#ifndef TEST_SHMCTL_BOGUS_ADDR
|
||||
-# define TEST_SHMCTL_BOGUS_ADDR 1
|
||||
-#endif
|
||||
-
|
||||
static int id = -1;
|
||||
|
||||
static void
|
||||
@@ -105,8 +118,12 @@ main(void)
|
||||
static const key_t private_key =
|
||||
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
|
||||
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
|
||||
+#if TEST_SHMCTL_BOGUS_CMD || TEST_SHMCTL_BOGUS_ADDR
|
||||
static const int bogus_id = 0xdefaced1;
|
||||
+#endif
|
||||
+#if TEST_SHMCTL_BOGUS_CMD
|
||||
static const int bogus_cmd = 0xdefaced2;
|
||||
+#endif
|
||||
#if TEST_SHMCTL_BOGUS_ADDR
|
||||
static void * const bogus_addr = (void *) -1L;
|
||||
#endif
|
||||
@@ -173,9 +190,11 @@ main(void)
|
||||
printf("shmget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id);
|
||||
atexit(cleanup);
|
||||
|
||||
+#if TEST_SHMCTL_BOGUS_CMD
|
||||
rc = shmctl(bogus_id, bogus_cmd, NULL);
|
||||
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
|
||||
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
|
||||
+#endif
|
||||
|
||||
#if TEST_SHMCTL_BOGUS_ADDR
|
||||
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
|
||||
diff --git a/tests-mx32/ipc_shm.c b/tests-mx32/ipc_shm.c
|
||||
index 695fd94..350bde5 100644
|
||||
--- a/tests-mx32/ipc_shm.c
|
||||
+++ b/tests-mx32/ipc_shm.c
|
||||
@@ -29,6 +29,34 @@
|
||||
# define SHM_NORESERVE 010000
|
||||
#endif
|
||||
|
||||
+#undef TEST_SHMCTL_BOGUS_ADDR
|
||||
+#undef TEST_SHMCTL_BOGUS_CMD
|
||||
+
|
||||
+/*
|
||||
+ * Starting with commit glibc-2.32~80, on every 32-bit architecture
|
||||
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
|
||||
+ * the data provided in the third argument of shmctl call.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
|
||||
+# define TEST_SHMCTL_BOGUS_ADDR 0
|
||||
+#endif
|
||||
+
|
||||
+/*
|
||||
+ * Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
|
||||
+ * glibc skips shmctl syscall invocations and returns EINVAL
|
||||
+ * for invalid shmctl commands.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 32)
|
||||
+# define TEST_SHMCTL_BOGUS_CMD 0
|
||||
+#endif
|
||||
+
|
||||
+#ifndef TEST_SHMCTL_BOGUS_ADDR
|
||||
+# define TEST_SHMCTL_BOGUS_ADDR 1
|
||||
+#endif
|
||||
+#ifndef TEST_SHMCTL_BOGUS_CMD
|
||||
+# define TEST_SHMCTL_BOGUS_CMD 1
|
||||
+#endif
|
||||
+
|
||||
#include "xlat.h"
|
||||
#include "xlat/shm_resource_flags.h"
|
||||
|
||||
@@ -73,21 +101,6 @@
|
||||
# define str_bogus_cmd "0xdefaced2 /\\* SHM_\\?\\?\\? \\*/"
|
||||
#endif
|
||||
|
||||
-#undef TEST_SHMCTL_BOGUS_ADDR
|
||||
-
|
||||
-/*
|
||||
- * Starting with commit glibc-2.32~80, on every 32-bit architecture
|
||||
- * where 32-bit time_t support is enabled, glibc tries to retrieve
|
||||
- * the data provided in the third argument of shmctl call.
|
||||
- */
|
||||
-#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
|
||||
-# define TEST_SHMCTL_BOGUS_ADDR 0
|
||||
-#endif
|
||||
-
|
||||
-#ifndef TEST_SHMCTL_BOGUS_ADDR
|
||||
-# define TEST_SHMCTL_BOGUS_ADDR 1
|
||||
-#endif
|
||||
-
|
||||
static int id = -1;
|
||||
|
||||
static void
|
||||
@@ -105,8 +118,12 @@ main(void)
|
||||
static const key_t private_key =
|
||||
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
|
||||
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
|
||||
+#if TEST_SHMCTL_BOGUS_CMD || TEST_SHMCTL_BOGUS_ADDR
|
||||
static const int bogus_id = 0xdefaced1;
|
||||
+#endif
|
||||
+#if TEST_SHMCTL_BOGUS_CMD
|
||||
static const int bogus_cmd = 0xdefaced2;
|
||||
+#endif
|
||||
#if TEST_SHMCTL_BOGUS_ADDR
|
||||
static void * const bogus_addr = (void *) -1L;
|
||||
#endif
|
||||
@@ -173,9 +190,11 @@ main(void)
|
||||
printf("shmget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id);
|
||||
atexit(cleanup);
|
||||
|
||||
+#if TEST_SHMCTL_BOGUS_CMD
|
||||
rc = shmctl(bogus_id, bogus_cmd, NULL);
|
||||
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
|
||||
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
|
||||
+#endif
|
||||
|
||||
#if TEST_SHMCTL_BOGUS_ADDR
|
||||
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
|
||||
--
|
||||
2.1.4
|
||||
|
@ -0,0 +1,199 @@
|
||||
From dd8d558394b2b8cb7f743a2a4bf763974d6c2dd9 Mon Sep 17 00:00:00 2001
|
||||
From: "Dmitry V. Levin" <ldv@altlinux.org>
|
||||
Date: Sun, 6 Dec 2020 08:00:00 +0000
|
||||
Subject: [PATCH 162/162] tests: disable tests for invalid semctl commands on
|
||||
glibc >= 2.32
|
||||
|
||||
Starting with commit glibc-2.32.9000-147-ga16d2abd496bd974a882,
|
||||
glibc skips semctl syscall invocations and returns EINVAL
|
||||
for invalid semctl commands.
|
||||
|
||||
* tests/ipc_sem.c [GLIBC_PREREQ_GE(2, 32)] (TEST_SEMCTL_BOGUS_CMD):
|
||||
Define to 0.
|
||||
[!TEST_SEMCTL_BOGUS_CMD] (TEST_SEMCTL_BOGUS_CMD): Define to 1.
|
||||
(main) [!TEST_SEMCTL_BOGUS_CMD] (bogus_semid, bogus_semnum, bogus_cmd,
|
||||
bogus_arg): Do not define and do not use.
|
||||
---
|
||||
tests/ipc_sem.c | 25 ++++++++++++++++++++++---
|
||||
1 file changed, 22 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/tests/ipc_sem.c b/tests/ipc_sem.c
|
||||
index 7341f72..0351e53 100644
|
||||
--- a/tests/ipc_sem.c
|
||||
+++ b/tests/ipc_sem.c
|
||||
@@ -20,6 +20,21 @@
|
||||
# define SEM_STAT_ANY 20
|
||||
#endif
|
||||
|
||||
+#undef TEST_SEMCTL_BOGUS_CMD
|
||||
+
|
||||
+/*
|
||||
+ * Starting with commit glibc-2.32.9000-147-ga16d2abd496bd974a882,
|
||||
+ * glibc skips semctl syscall invocations and returns EINVAL
|
||||
+ * for invalid semctl commands.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 32)
|
||||
+# define TEST_SEMCTL_BOGUS_CMD 0
|
||||
+#endif
|
||||
+
|
||||
+#ifndef TEST_SEMCTL_BOGUS_CMD
|
||||
+# define TEST_SEMCTL_BOGUS_CMD 1
|
||||
+#endif
|
||||
+
|
||||
#if XLAT_RAW
|
||||
# define str_ipc_flags "0xface1e00"
|
||||
# define str_ipc_private "0"
|
||||
@@ -78,13 +93,15 @@ main(void)
|
||||
static const key_t private_key =
|
||||
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
|
||||
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
|
||||
- static const int bogus_semid = 0xfdb97531;
|
||||
- static const int bogus_semnum = 0xeca86420;
|
||||
static const int bogus_size = 0xdec0ded1;
|
||||
static const int bogus_flags = 0xface1e55;
|
||||
+#if TEST_SEMCTL_BOGUS_CMD
|
||||
+ static const int bogus_semid = 0xfdb97531;
|
||||
+ static const int bogus_semnum = 0xeca86420;
|
||||
static const int bogus_cmd = 0xdeadbeef;
|
||||
static const unsigned long bogus_arg =
|
||||
(unsigned long) 0xbadc0dedfffffaceULL;
|
||||
+#endif
|
||||
|
||||
int rc;
|
||||
union semun un;
|
||||
@@ -102,11 +119,13 @@ main(void)
|
||||
printf("semget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id);
|
||||
atexit(cleanup);
|
||||
|
||||
+#if TEST_SEMCTL_BOGUS_CMD
|
||||
rc = semctl(bogus_semid, bogus_semnum, bogus_cmd, bogus_arg);
|
||||
-#define SEMCTL_BOGUS_ARG_FMT "(%#lx|\\[(%#lx|NULL)\\]|NULL)"
|
||||
+# define SEMCTL_BOGUS_ARG_FMT "(%#lx|\\[(%#lx|NULL)\\]|NULL)"
|
||||
printf("semctl\\(%d, %d, (%s\\|)?%s, " SEMCTL_BOGUS_ARG_FMT "\\) = %s\n",
|
||||
bogus_semid, bogus_semnum, str_ipc_64, str_bogus_cmd,
|
||||
bogus_arg, bogus_arg, sprintrc_grep(rc));
|
||||
+#endif
|
||||
|
||||
un.buf = &ds;
|
||||
if (semctl(id, 0, IPC_STAT, un))
|
||||
diff --git a/tests-m32/ipc_sem.c b/tests-m32/ipc_sem.c
|
||||
index 7341f72..0351e53 100644
|
||||
--- a/tests-m32/ipc_sem.c
|
||||
+++ b/tests-m32/ipc_sem.c
|
||||
@@ -20,6 +20,21 @@
|
||||
# define SEM_STAT_ANY 20
|
||||
#endif
|
||||
|
||||
+#undef TEST_SEMCTL_BOGUS_CMD
|
||||
+
|
||||
+/*
|
||||
+ * Starting with commit glibc-2.32.9000-147-ga16d2abd496bd974a882,
|
||||
+ * glibc skips semctl syscall invocations and returns EINVAL
|
||||
+ * for invalid semctl commands.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 32)
|
||||
+# define TEST_SEMCTL_BOGUS_CMD 0
|
||||
+#endif
|
||||
+
|
||||
+#ifndef TEST_SEMCTL_BOGUS_CMD
|
||||
+# define TEST_SEMCTL_BOGUS_CMD 1
|
||||
+#endif
|
||||
+
|
||||
#if XLAT_RAW
|
||||
# define str_ipc_flags "0xface1e00"
|
||||
# define str_ipc_private "0"
|
||||
@@ -78,13 +93,15 @@ main(void)
|
||||
static const key_t private_key =
|
||||
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
|
||||
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
|
||||
- static const int bogus_semid = 0xfdb97531;
|
||||
- static const int bogus_semnum = 0xeca86420;
|
||||
static const int bogus_size = 0xdec0ded1;
|
||||
static const int bogus_flags = 0xface1e55;
|
||||
+#if TEST_SEMCTL_BOGUS_CMD
|
||||
+ static const int bogus_semid = 0xfdb97531;
|
||||
+ static const int bogus_semnum = 0xeca86420;
|
||||
static const int bogus_cmd = 0xdeadbeef;
|
||||
static const unsigned long bogus_arg =
|
||||
(unsigned long) 0xbadc0dedfffffaceULL;
|
||||
+#endif
|
||||
|
||||
int rc;
|
||||
union semun un;
|
||||
@@ -102,11 +119,13 @@ main(void)
|
||||
printf("semget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id);
|
||||
atexit(cleanup);
|
||||
|
||||
+#if TEST_SEMCTL_BOGUS_CMD
|
||||
rc = semctl(bogus_semid, bogus_semnum, bogus_cmd, bogus_arg);
|
||||
-#define SEMCTL_BOGUS_ARG_FMT "(%#lx|\\[(%#lx|NULL)\\]|NULL)"
|
||||
+# define SEMCTL_BOGUS_ARG_FMT "(%#lx|\\[(%#lx|NULL)\\]|NULL)"
|
||||
printf("semctl\\(%d, %d, (%s\\|)?%s, " SEMCTL_BOGUS_ARG_FMT "\\) = %s\n",
|
||||
bogus_semid, bogus_semnum, str_ipc_64, str_bogus_cmd,
|
||||
bogus_arg, bogus_arg, sprintrc_grep(rc));
|
||||
+#endif
|
||||
|
||||
un.buf = &ds;
|
||||
if (semctl(id, 0, IPC_STAT, un))
|
||||
diff --git a/tests-mx32/ipc_sem.c b/tests-mx32/ipc_sem.c
|
||||
index 7341f72..0351e53 100644
|
||||
--- a/tests-mx32/ipc_sem.c
|
||||
+++ b/tests-mx32/ipc_sem.c
|
||||
@@ -20,6 +20,21 @@
|
||||
# define SEM_STAT_ANY 20
|
||||
#endif
|
||||
|
||||
+#undef TEST_SEMCTL_BOGUS_CMD
|
||||
+
|
||||
+/*
|
||||
+ * Starting with commit glibc-2.32.9000-147-ga16d2abd496bd974a882,
|
||||
+ * glibc skips semctl syscall invocations and returns EINVAL
|
||||
+ * for invalid semctl commands.
|
||||
+ */
|
||||
+#if GLIBC_PREREQ_GE(2, 32)
|
||||
+# define TEST_SEMCTL_BOGUS_CMD 0
|
||||
+#endif
|
||||
+
|
||||
+#ifndef TEST_SEMCTL_BOGUS_CMD
|
||||
+# define TEST_SEMCTL_BOGUS_CMD 1
|
||||
+#endif
|
||||
+
|
||||
#if XLAT_RAW
|
||||
# define str_ipc_flags "0xface1e00"
|
||||
# define str_ipc_private "0"
|
||||
@@ -78,13 +93,15 @@ main(void)
|
||||
static const key_t private_key =
|
||||
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
|
||||
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
|
||||
- static const int bogus_semid = 0xfdb97531;
|
||||
- static const int bogus_semnum = 0xeca86420;
|
||||
static const int bogus_size = 0xdec0ded1;
|
||||
static const int bogus_flags = 0xface1e55;
|
||||
+#if TEST_SEMCTL_BOGUS_CMD
|
||||
+ static const int bogus_semid = 0xfdb97531;
|
||||
+ static const int bogus_semnum = 0xeca86420;
|
||||
static const int bogus_cmd = 0xdeadbeef;
|
||||
static const unsigned long bogus_arg =
|
||||
(unsigned long) 0xbadc0dedfffffaceULL;
|
||||
+#endif
|
||||
|
||||
int rc;
|
||||
union semun un;
|
||||
@@ -102,11 +119,13 @@ main(void)
|
||||
printf("semget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id);
|
||||
atexit(cleanup);
|
||||
|
||||
+#if TEST_SEMCTL_BOGUS_CMD
|
||||
rc = semctl(bogus_semid, bogus_semnum, bogus_cmd, bogus_arg);
|
||||
-#define SEMCTL_BOGUS_ARG_FMT "(%#lx|\\[(%#lx|NULL)\\]|NULL)"
|
||||
+# define SEMCTL_BOGUS_ARG_FMT "(%#lx|\\[(%#lx|NULL)\\]|NULL)"
|
||||
printf("semctl\\(%d, %d, (%s\\|)?%s, " SEMCTL_BOGUS_ARG_FMT "\\) = %s\n",
|
||||
bogus_semid, bogus_semnum, str_ipc_64, str_bogus_cmd,
|
||||
bogus_arg, bogus_arg, sprintrc_grep(rc));
|
||||
+#endif
|
||||
|
||||
un.buf = &ds;
|
||||
if (semctl(id, 0, IPC_STAT, un))
|
||||
--
|
||||
2.1.4
|
||||
|
@ -0,0 +1,135 @@
|
||||
Index: strace-5.7/tests/ipc_msg.c
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests/ipc_msg.c 2021-08-24 21:39:53.102419769 +0200
|
||||
+++ strace-5.7/tests/ipc_msg.c 2021-08-24 21:43:00.670841489 +0200
|
||||
@@ -55,8 +55,9 @@
|
||||
* Starting with commit glibc-2.32.9000-149-gbe9b0b9a012780a403a2,
|
||||
* glibc skips msgctl syscall invocations and returns EINVAL
|
||||
* for invalid msgctl commands.
|
||||
+ * It has been backported into glic-2.28-153 in RHEL 8.5.
|
||||
*/
|
||||
-#if GLIBC_PREREQ_GE(2, 32)
|
||||
+#if GLIBC_PREREQ_GE(2, 28)
|
||||
# define TEST_MSGCTL_BOGUS_CMD 0
|
||||
#endif
|
||||
|
||||
Index: strace-5.7/tests/ipc_shm.c
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests/ipc_shm.c 2021-08-24 21:39:53.124419583 +0200
|
||||
+++ strace-5.7/tests/ipc_shm.c 2021-08-24 21:43:00.670841489 +0200
|
||||
@@ -45,8 +45,9 @@
|
||||
* Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
|
||||
* glibc skips shmctl syscall invocations and returns EINVAL
|
||||
* for invalid shmctl commands.
|
||||
+ * It has been backported into glic-2.28-153 in RHEL 8.5.
|
||||
*/
|
||||
-#if GLIBC_PREREQ_GE(2, 32)
|
||||
+#if GLIBC_PREREQ_GE(2, 28)
|
||||
# define TEST_SHMCTL_BOGUS_CMD 0
|
||||
#endif
|
||||
|
||||
Index: strace-5.7/tests/ipc_sem.c
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests/ipc_sem.c 2021-08-24 21:39:53.135419490 +0200
|
||||
+++ strace-5.7/tests/ipc_sem.c 2021-08-24 21:43:00.670841489 +0200
|
||||
@@ -26,8 +26,9 @@
|
||||
* Starting with commit glibc-2.32.9000-147-ga16d2abd496bd974a882,
|
||||
* glibc skips semctl syscall invocations and returns EINVAL
|
||||
* for invalid semctl commands.
|
||||
+ * It has been backported into glic-2.28-153 in RHEL 8.5.
|
||||
*/
|
||||
-#if GLIBC_PREREQ_GE(2, 32)
|
||||
+#if GLIBC_PREREQ_GE(2, 28)
|
||||
# define TEST_SEMCTL_BOGUS_CMD 0
|
||||
#endif
|
||||
|
||||
Index: strace-5.7/tests-m32/ipc_msg.c
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests-m32/ipc_msg.c 2021-08-24 21:39:53.102419769 +0200
|
||||
+++ strace-5.7/tests-m32/ipc_msg.c 2021-08-24 21:43:00.670841489 +0200
|
||||
@@ -55,8 +55,9 @@
|
||||
* Starting with commit glibc-2.32.9000-149-gbe9b0b9a012780a403a2,
|
||||
* glibc skips msgctl syscall invocations and returns EINVAL
|
||||
* for invalid msgctl commands.
|
||||
+ * It has been backported into glic-2.28-153 in RHEL 8.5.
|
||||
*/
|
||||
-#if GLIBC_PREREQ_GE(2, 32)
|
||||
+#if GLIBC_PREREQ_GE(2, 28)
|
||||
# define TEST_MSGCTL_BOGUS_CMD 0
|
||||
#endif
|
||||
|
||||
Index: strace-5.7/tests-m32/ipc_shm.c
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests-m32/ipc_shm.c 2021-08-24 21:39:53.124419583 +0200
|
||||
+++ strace-5.7/tests-m32/ipc_shm.c 2021-08-24 21:43:00.671841481 +0200
|
||||
@@ -45,8 +45,9 @@
|
||||
* Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
|
||||
* glibc skips shmctl syscall invocations and returns EINVAL
|
||||
* for invalid shmctl commands.
|
||||
+ * It has been backported into glic-2.28-153 in RHEL 8.5.
|
||||
*/
|
||||
-#if GLIBC_PREREQ_GE(2, 32)
|
||||
+#if GLIBC_PREREQ_GE(2, 28)
|
||||
# define TEST_SHMCTL_BOGUS_CMD 0
|
||||
#endif
|
||||
|
||||
Index: strace-5.7/tests-m32/ipc_sem.c
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests-m32/ipc_sem.c 2021-08-24 21:39:53.135419490 +0200
|
||||
+++ strace-5.7/tests-m32/ipc_sem.c 2021-08-24 21:43:00.671841481 +0200
|
||||
@@ -26,8 +26,9 @@
|
||||
* Starting with commit glibc-2.32.9000-147-ga16d2abd496bd974a882,
|
||||
* glibc skips semctl syscall invocations and returns EINVAL
|
||||
* for invalid semctl commands.
|
||||
+ * It has been backported into glic-2.28-153 in RHEL 8.5.
|
||||
*/
|
||||
-#if GLIBC_PREREQ_GE(2, 32)
|
||||
+#if GLIBC_PREREQ_GE(2, 28)
|
||||
# define TEST_SEMCTL_BOGUS_CMD 0
|
||||
#endif
|
||||
|
||||
Index: strace-5.7/tests-mx32/ipc_msg.c
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests-mx32/ipc_msg.c 2021-08-24 21:39:53.102419769 +0200
|
||||
+++ strace-5.7/tests-mx32/ipc_msg.c 2021-08-24 21:43:00.671841481 +0200
|
||||
@@ -55,8 +55,9 @@
|
||||
* Starting with commit glibc-2.32.9000-149-gbe9b0b9a012780a403a2,
|
||||
* glibc skips msgctl syscall invocations and returns EINVAL
|
||||
* for invalid msgctl commands.
|
||||
+ * It has been backported into glic-2.28-153 in RHEL 8.5.
|
||||
*/
|
||||
-#if GLIBC_PREREQ_GE(2, 32)
|
||||
+#if GLIBC_PREREQ_GE(2, 28)
|
||||
# define TEST_MSGCTL_BOGUS_CMD 0
|
||||
#endif
|
||||
|
||||
Index: strace-5.7/tests-mx32/ipc_shm.c
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests-mx32/ipc_shm.c 2021-08-24 21:39:53.124419583 +0200
|
||||
+++ strace-5.7/tests-mx32/ipc_shm.c 2021-08-24 21:43:00.671841481 +0200
|
||||
@@ -45,8 +45,9 @@
|
||||
* Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
|
||||
* glibc skips shmctl syscall invocations and returns EINVAL
|
||||
* for invalid shmctl commands.
|
||||
+ * It has been backported into glic-2.28-153 in RHEL 8.5.
|
||||
*/
|
||||
-#if GLIBC_PREREQ_GE(2, 32)
|
||||
+#if GLIBC_PREREQ_GE(2, 28)
|
||||
# define TEST_SHMCTL_BOGUS_CMD 0
|
||||
#endif
|
||||
|
||||
Index: strace-5.7/tests-mx32/ipc_sem.c
|
||||
===================================================================
|
||||
--- strace-5.7.orig/tests-mx32/ipc_sem.c 2021-08-24 21:39:53.136419481 +0200
|
||||
+++ strace-5.7/tests-mx32/ipc_sem.c 2021-08-24 21:43:00.672841472 +0200
|
||||
@@ -26,8 +26,9 @@
|
||||
* Starting with commit glibc-2.32.9000-147-ga16d2abd496bd974a882,
|
||||
* glibc skips semctl syscall invocations and returns EINVAL
|
||||
* for invalid semctl commands.
|
||||
+ * It has been backported into glic-2.28-153 in RHEL 8.5.
|
||||
*/
|
||||
-#if GLIBC_PREREQ_GE(2, 32)
|
||||
+#if GLIBC_PREREQ_GE(2, 28)
|
||||
# define TEST_SEMCTL_BOGUS_CMD 0
|
||||
#endif
|
||||
|
@ -1,7 +1,7 @@
|
||||
Summary: Tracks and displays system calls associated with a running process
|
||||
Name: strace
|
||||
Version: 5.7
|
||||
Release: 2%{?dist}
|
||||
Release: 2.1%{?dist}
|
||||
# The test suite is GPLv2+, all the rest is LGPLv2.1+.
|
||||
License: LGPL-2.1+ and GPL-2.0+
|
||||
Group: Development/Debuggers
|
||||
@ -11,6 +11,7 @@ Source: https://strace.io/files/%{version}/%{name}-%{version}.tar.xz
|
||||
BuildRequires: libacl-devel time gcc gzip
|
||||
BuildRequires: pkgconfig(bluez)
|
||||
BuildRequires: elfutils-devel binutils-devel
|
||||
BuildRequires: libselinux-devel
|
||||
|
||||
## Reported by covscan
|
||||
## v5.2-3-g7ada13f "evdev: avoid bit vector decoding on non-successful and 0 return codes"
|
||||
@ -201,6 +202,40 @@ Patch137: 0137-Implement-testing-framework-for-pidns.patch
|
||||
# v5.8-9-gf350ce0 "Add tests for PID namespace translation"
|
||||
Patch138: 0138-Add-tests-for-PID-namespace-translation.patch
|
||||
|
||||
# v5.12~55 "tests: add fchmod-y test"
|
||||
Patch142: 0142-tests-add-fchmod-y-test.patch
|
||||
# v5.12~54 "tests: introduce create_and_enter_subdir and leave_and_remove_subdir"
|
||||
Patch143: 0143-tests-introduce-create_and_enter_subdir-and-leave_an.patch
|
||||
# v5.8~36 "tests: check decoding of faccessat syscall in -P, -y, and -yy modes"
|
||||
Patch144: 0144-tests-check-decoding-of-faccessat-syscall-in-P-y-and.patch
|
||||
# v5.12~97 "xmalloc: introduce xasprintf"
|
||||
Patch145: 0145-xmalloc-introduce-xasprintf.patch
|
||||
# v5.12~96 "tests: use xasprintf instead of asprintf"
|
||||
Patch146: 0146-tests-use-xasprintf-instead-of-asprintf.patch
|
||||
# v5.12~156 "file_handle: print f_handle as a hexadecimal string"
|
||||
Patch147: 0147-file_handle-print-f_handle-as-a-hexadecimal-string.patch
|
||||
# v5.10~47 "tests: fix execve test with fresh linux kernels"
|
||||
Patch148: 0148-tests-fix-execve-test-with-fresh-linux-kernels.patch
|
||||
# v5.12~49 "Implement --secontext[=full] option to display SELinux contexts"
|
||||
Patch149: 0149-Implement-secontext-full-option-to-display-SELinux-c.patch
|
||||
# v5.13-14-g9623154 "m4/mpers.m4: generate HAVE_*_SELINUX_RUNTIME config defines"
|
||||
Patch155: 0155-m4-mpers.m4-generate-HAVE_-_SELINUX_RUNTIME-config-d.patch
|
||||
|
||||
# v5.9~28 "Introduce GLIBC_PREREQ_GE and GLIBC_PREREQ_LT macros"
|
||||
Patch156: 0156-Introduce-GLIBC_PREREQ_GE-and-GLIBC_PREREQ_LT-macros.patch
|
||||
# v5.9~27 "tests/ipc_msg.c: disable TEST_MSGCTL_BOGUS_ADDR on glibc >= 2.32"
|
||||
Patch157: 0157-tests-ipc_msg.c-disable-TEST_MSGCTL_BOGUS_ADDR-on-gl.patch
|
||||
# v5.10~46 "tests: disable TEST_MSGCTL_BOGUS_ADDR in ipc_msg test on glibc >= 2.31"
|
||||
Patch158: 0158-tests-disable-TEST_MSGCTL_BOGUS_ADDR-in-ipc_msg-test.patch
|
||||
# v5.10~22 "tests: disable tests for invalid msgctl commands on glibc >= 2.32"
|
||||
Patch159: 0159-tests-disable-tests-for-invalid-msgctl-commands-on-g.patch
|
||||
# v5.9~11 "tests: disable shmctl IPC_STAT test with a bogus address on glibc >= 2.32"
|
||||
Patch160: 0160-tests-disable-shmctl-IPC_STAT-test-with-a-bogus-addr.patch
|
||||
# v5.9~10 "tests: disable tests for invalid shmctl commands on glibc >= 2.32"
|
||||
Patch161: 0161-tests-disable-tests-for-invalid-shmctl-commands-on-g.patch
|
||||
# v5.9~12 "tests: disable tests for invalid semctl commands on glibc >= 2.32"
|
||||
Patch162: 0162-tests-disable-tests-for-invalid-semctl-commands-on-g.patch
|
||||
|
||||
### Wire up rseq and kexec_file_load in order to avoid kexec_file_load
|
||||
### test failure on aarch64. Addresses https://bugzilla.redhat.com/1676045
|
||||
### ("strace: FTBFS in Fedora rawhide/f30").
|
||||
@ -217,6 +252,10 @@ Patch2001: 2001-limit-qual_fault-scope-on-aarch64.patch
|
||||
#Patch2002: 2002-disable-ksysent-on-8.2.patch
|
||||
## RHEL-only: avoid ARRAY_SIZE macro re-definition in libiberty.h
|
||||
Patch2003: 2003-undef-ARRAY_SIZE.patch
|
||||
## RHEL-only: glibc-2.32.9000-147-ga16d2abd496bd974a882,
|
||||
## glibc-2.32.9000-149-gbe9b0b9a012780a403a2 and
|
||||
## glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f have been backported in RHEL.
|
||||
Patch2004: 2004-glibc-msgctl-semctl-shmctl-backport-workaround.patch
|
||||
|
||||
|
||||
# We no longer need to build a separate strace32 binary, but we don't want
|
||||
@ -319,6 +358,22 @@ received by a process.
|
||||
%patch136 -p1
|
||||
%patch137 -p1
|
||||
%patch138 -p1
|
||||
%patch142 -p1
|
||||
%patch143 -p1
|
||||
%patch144 -p1
|
||||
%patch145 -p1
|
||||
%patch146 -p1
|
||||
%patch147 -p1
|
||||
%patch148 -p1
|
||||
%patch149 -p1
|
||||
%patch155 -p1
|
||||
%patch156 -p1
|
||||
%patch157 -p1
|
||||
%patch158 -p1
|
||||
%patch159 -p1
|
||||
%patch160 -p1
|
||||
%patch161 -p1
|
||||
%patch162 -p1
|
||||
|
||||
#%patch1000 -p1
|
||||
#%patch1001 -p1
|
||||
@ -327,6 +382,7 @@ received by a process.
|
||||
%patch2001 -p1
|
||||
#%patch2002 -p1
|
||||
%patch2003 -p1
|
||||
%patch2004 -p1
|
||||
|
||||
chmod a+x tests/*.test
|
||||
|
||||
@ -405,6 +461,9 @@ echo 'END OF TEST SUITE INFORMATION'
|
||||
%{_mandir}/man1/*
|
||||
|
||||
%changelog
|
||||
* Thu Sep 02 2021 Eugene Syromiatnikov <esyr@redhat.com> - 5.7-2.1
|
||||
- Add SELnux context decoding support (#2000565).
|
||||
|
||||
* Mon Nov 09 2020 Eugene Syromiatnikov <esyr@redhat.com> - 5.7-2
|
||||
- Add PID namespace translation support (#1725113).
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user