]> granicus.if.org Git - strace/commitdiff
Implement decoding of move_mount syscall
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 25 Jun 2019 11:32:26 +0000 (11:32 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 29 Jun 2019 17:38:25 +0000 (17:38 +0000)
... introduced by Linux kernel commits v5.2-rc1~141^2~8,
v5.2-rc1~20^2~1, and v5.2-rc1~20^2.

* move_mount.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* pathtrace.c (pathtrace_match_set): Add SEN_move_mount.
* xlat/move_mount_flags.in: New file.
* linux/syscallent-common.h [BASE_NR + 429]: Wire up move_mount.
* NEWS: Mention this change.
* tests/move_mount.c: New file.
* tests/move_mount-P.c: Likewise.
* tests/gen_tests.in (move_mount, move_mount-P): New entries.
* tests/pure_executables.list: Add move_mount and move_mount-P.
* tests/.gitignore: Likewise.

Makefile.am
NEWS
linux/syscallent-common.h
move_mount.c [new file with mode: 0644]
pathtrace.c
tests/.gitignore
tests/gen_tests.in
tests/move_mount-P.c [new file with mode: 0644]
tests/move_mount.c [new file with mode: 0644]
tests/pure_executables.list
xlat/move_mount_flags.in [new file with mode: 0644]

index 4c56935a56fd5f10fac8ac128a8e575f5cfde597..d4f9e1a886b07db7df56321dc850463e5c7cb1e4 100644 (file)
@@ -186,6 +186,7 @@ strace_SOURCES =    \
        mmap_notify.h   \
        mmsghdr.c       \
        mount.c         \
+       move_mount.c    \
        mpers_type.h    \
        mq.c            \
        msghdr.c        \
diff --git a/NEWS b/NEWS
index 8a21b789425f92fe76cea30c30028bf1914064d8..34bea8186062358c4f3fa1d909c93775df289101 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,7 @@ Noteworthy changes in release ?.? (????-??-??)
 ==============================================
 
 * Improvements
-  * Implemented decoding of open_tree syscall.
+  * Implemented decoding of open_tree and move_mount syscalls.
   * Enhanced decoding of clone syscall.
   * Updated lists of AT_*, AUDIT_*, CLONE_*, ETH_*, KEY_*, KVM_*, TIPC_*,
     and V4L2_* constants.
index 6d404d2dcf38ad9bae5e7d1de5352c9a95a5af47..6844404f41105922f251b1327a06fda5b3680081 100644 (file)
@@ -13,3 +13,4 @@
 [BASE_NR + 426] = { 6, TD|TS,          SEN(io_uring_enter),            "io_uring_enter"        },
 [BASE_NR + 427] = { 4, TD|TM,          SEN(io_uring_register),         "io_uring_register"     },
 [BASE_NR + 428] = { 3, TD|TF,          SEN(open_tree),                 "open_tree"             },
+[BASE_NR + 429] = { 5, TD|TF,          SEN(move_mount),                "move_mount"            },
diff --git a/move_mount.c b/move_mount.c
new file mode 100644 (file)
index 0000000..b299b73
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2019 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "defs.h"
+#ifdef HAVE_LINUX_MOUNT_H
+# include <linux/mount.h>
+#endif
+#include "xlat/move_mount_flags.h"
+
+SYS_FUNC(move_mount)
+{
+       print_dirfd(tcp, tcp->u_arg[0]);
+       printpath(tcp, tcp->u_arg[1]);
+       tprints(", ");
+       print_dirfd(tcp, tcp->u_arg[2]);
+       printpath(tcp, tcp->u_arg[3]);
+       tprints(", ");
+       printflags(move_mount_flags, tcp->u_arg[4], "MOVE_MOUNT_???");
+       return RVAL_DECODED;
+}
index 53ac8031342014c06307cd31a50943ea2a2177ec..23667798a74bf5e9eafccfad6e8e9876536d1d7d 100644 (file)
@@ -223,6 +223,7 @@ pathtrace_match_set(struct tcb *tcp, struct path_set *set)
                return upathmatch(tcp, tcp->u_arg[1], set);
 
        case SEN_linkat:
+       case SEN_move_mount:
        case SEN_renameat2:
        case SEN_renameat:
                /* fd, path, fd, path */
index e51895cec7e53daab80674b7007687264ec7bbbe..7234060618a2b31bcbefcd41198b5f29ccc74f5e 100644 (file)
@@ -265,6 +265,8 @@ mount
 mount-Xabbrev
 mount-Xraw
 mount-Xverbose
+move_mount
+move_mount-P
 move_pages
 move_pages-Xabbrev
 move_pages-Xraw
index 45fc5e5aa512fdaacbc6a302abf5d7c8bcb93742..58afdc4ef52be96cbe23844d50f90357360758ff 100644 (file)
@@ -223,6 +223,8 @@ mount               -a33
 mount-Xabbrev  -a33 -e trace=mount -Xabbrev
 mount-Xraw     -a33 -e trace=mount -Xraw
 mount-Xverbose -a33 -e trace=mount -Xverbose
+move_mount     -y
+move_mount-P   -y -P /dev/full -e trace=move_mount
 move_pages     -s3
 move_pages-Xabbrev     -s3 -e trace=move_pages -Xabbrev
 move_pages-Xraw        -s3 -a36 -e trace=move_pages -Xraw
diff --git a/tests/move_mount-P.c b/tests/move_mount-P.c
new file mode 100644 (file)
index 0000000..1e1cd5c
--- /dev/null
@@ -0,0 +1,2 @@
+#define PATH_TRACING
+#include "move_mount.c"
diff --git a/tests/move_mount.c b/tests/move_mount.c
new file mode 100644 (file)
index 0000000..6df3949
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Check decoding of move_mount syscall.
+ *
+ * Copyright (c) 2019 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "tests.h"
+#include <asm/unistd.h>
+#include "scno.h"
+
+#ifdef __NR_move_mount
+
+# include <fcntl.h>
+# include <limits.h>
+# include <stdio.h>
+# include <stdint.h>
+# include <unistd.h>
+
+static const char *errstr;
+
+static long
+k_move_mount(const unsigned int from_dfd, const void *from_fname,
+            const unsigned int to_dfd, const void *to_fname,
+            const unsigned int flags)
+{
+       const kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
+       const kernel_ulong_t bad = (kernel_ulong_t) 0xbadc0dedbadc0dedULL;
+       const kernel_ulong_t arg1 = fill | from_dfd;
+       const kernel_ulong_t arg2 = (uintptr_t) from_fname;
+       const kernel_ulong_t arg3 = fill | to_dfd;
+       const kernel_ulong_t arg4 = (uintptr_t) to_fname;
+       const kernel_ulong_t arg5 = fill | flags;
+       const long rc = syscall(__NR_move_mount,
+                               arg1, arg2, arg3, arg4, arg5, bad);
+       errstr = sprintrc(rc);
+       return rc;
+}
+
+int
+main(void)
+{
+       skip_if_unavailable("/proc/self/fd/");
+
+       static const char path_full[] = "/dev/full";
+       const char *const path = tail_memdup(path_full, sizeof(path_full));
+       const void *const efault = path + sizeof(path_full);
+       const char *const empty = efault - 1;
+       char *const fname = tail_alloc(PATH_MAX);
+       fill_memory_ex(fname, PATH_MAX, '0', 10);
+
+        int dfd = open(path, O_WRONLY);
+        if (dfd < 0)
+                perror_msg_and_fail("open: %s", path);
+
+       k_move_mount(-1, 0, -100, efault, 0);
+# ifndef PATH_TRACING
+       printf("move_mount(-1, NULL, AT_FDCWD, %p, 0) = %s\n", efault, errstr);
+# endif
+
+       k_move_mount(-100, efault, -1, 0, 0);
+# ifndef PATH_TRACING
+       printf("move_mount(AT_FDCWD, %p, -1, NULL, 0) = %s\n", efault, errstr);
+# endif
+
+       k_move_mount(dfd, fname, -100, empty, 1);
+       printf("move_mount(%d<%s>, \"%.*s\"..., AT_FDCWD, \"\", %s) = %s\n",
+              dfd, path, (int) PATH_MAX - 1, fname, "MOVE_MOUNT_F_SYMLINKS", errstr);
+
+       k_move_mount(-100, empty, dfd, fname, 0x10);
+       printf("move_mount(AT_FDCWD, \"\", %d<%s>, \"%.*s\"..., %s) = %s\n",
+              dfd, path, (int) PATH_MAX - 1, fname, "MOVE_MOUNT_T_SYMLINKS", errstr);
+
+# define f_flags_str "MOVE_MOUNT_F_SYMLINKS|MOVE_MOUNT_F_AUTOMOUNTS|MOVE_MOUNT_F_EMPTY_PATH"
+       fname[PATH_MAX - 1] = '\0';
+       k_move_mount(dfd, fname, -100, empty, 7);
+       printf("move_mount(%d<%s>, \"%s\", AT_FDCWD, \"\", %s) = %s\n",
+              dfd, path, fname, f_flags_str, errstr);
+
+# define t_flags_str "MOVE_MOUNT_T_SYMLINKS|MOVE_MOUNT_T_AUTOMOUNTS|MOVE_MOUNT_T_EMPTY_PATH"
+       k_move_mount(-100, empty, dfd, fname, 0x70);
+       printf("move_mount(AT_FDCWD, \"\", %d<%s>, \"%s\", %s) = %s\n",
+              dfd, path, fname, t_flags_str, errstr);
+
+       k_move_mount(-1, path, -100, empty, 0x77);
+       printf("move_mount(-1, \"%s\", AT_FDCWD, \"\", %s) = %s\n",
+              path, f_flags_str "|" t_flags_str, errstr);
+
+       k_move_mount(-100, empty, -1, path, -1);
+       printf("move_mount(AT_FDCWD, \"\", -1, \"%s\", %s) = %s\n",
+              path, f_flags_str "|" t_flags_str "|0xffffff88", errstr);
+
+       puts("+++ exited with 0 +++");
+       return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_move_mount")
+
+#endif
index e6e99abedbcd418c3381fe140e38122d85e64fa8..6e57eda5f8f5f5bf15fff8d5e65ee84fb5fc3026 100755 (executable)
@@ -223,6 +223,8 @@ mount
 mount-Xabbrev
 mount-Xraw
 mount-Xverbose
+move_mount
+move_mount-P
 move_pages
 move_pages-Xabbrev
 move_pages-Xraw
diff --git a/xlat/move_mount_flags.in b/xlat/move_mount_flags.in
new file mode 100644 (file)
index 0000000..441387c
--- /dev/null
@@ -0,0 +1,6 @@
+MOVE_MOUNT_F_SYMLINKS  0x01
+MOVE_MOUNT_F_AUTOMOUNTS        0x02
+MOVE_MOUNT_F_EMPTY_PATH        0x04
+MOVE_MOUNT_T_SYMLINKS  0x10
+MOVE_MOUNT_T_AUTOMOUNTS        0x20
+MOVE_MOUNT_T_EMPTY_PATH        0x40