Browse Source

Implement decoding of fsmount syscall

... introduced by Linux kernel commits v5.2-rc1~141^2~2,
v5.2-rc1~20^2~1, and v5.2-rc1~20^2.

* fsmount.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* pathtrace.c (pathtrace_match_set): Add SEN_fsmount.
* xlat/fsmount_cmds.in: New file.
* xlat/mount_attr_atime.in: Likewise.
* xlat/mount_attr_flags.in: Likewise.
* linux/syscallent-common.h [BASE_NR + 432]: Wire up fsmount.
* NEWS: Mention this change.
* tests/fsmount.c: New file.
* tests/gen_tests.in (fsmount): New entry.
* tests/pure_executables.list: Add fsmount.
* tests/.gitignore: Likewise.
Dmitry V. Levin 4 months ago
parent
commit
bd2e4cfc74
11 changed files with 139 additions and 1 deletions
  1. 1
    0
      Makefile.am
  2. 1
    1
      NEWS
  3. 26
    0
      fsmount.c
  4. 1
    0
      linux/syscallent-common.h
  5. 1
    0
      pathtrace.c
  6. 1
    0
      tests/.gitignore
  7. 98
    0
      tests/fsmount.c
  8. 1
    0
      tests/gen_tests.in
  9. 1
    0
      tests/pure_executables.list
  10. 1
    0
      xlat/fsmount_flags.in
  11. 7
    0
      xlat/mount_attr_flags.in

+ 1
- 0
Makefile.am View File

@@ -133,6 +133,7 @@ strace_SOURCES =	\
133 133
 	flock.h		\
134 134
 	fs_x_ioctl.c	\
135 135
 	fsconfig.c	\
136
+	fsmount.c	\
136 137
 	fsopen.c	\
137 138
 	futex.c		\
138 139
 	gcc_compat.h	\

+ 1
- 1
NEWS View File

@@ -2,7 +2,7 @@ Noteworthy changes in release ?.? (????-??-??)
2 2
 ==============================================
3 3
 
4 4
 * Improvements
5
-  * Implemented decoding of open_tree, move_mount, fsopen, and fsconfig
5
+  * Implemented decoding of open_tree, move_mount, fsopen, fsconfig, and fsmount
6 6
     syscalls.
7 7
   * Enhanced decoding of clone syscall.
8 8
   * Updated lists of AT_*, AUDIT_*, CLONE_*, ETH_*, KEY_*, KVM_*, TIPC_*,

+ 26
- 0
fsmount.c View File

@@ -0,0 +1,26 @@
1
+/*
2
+ * Copyright (c) 2019 Dmitry V. Levin <ldv@altlinux.org>
3
+ * All rights reserved.
4
+ *
5
+ * SPDX-License-Identifier: LGPL-2.1-or-later
6
+ */
7
+
8
+#include "defs.h"
9
+#ifdef HAVE_LINUX_MOUNT_H
10
+# include <linux/mount.h>
11
+#endif
12
+#include "xlat/fsmount_flags.h"
13
+#include "xlat/mount_attr_flags.h"
14
+
15
+SYS_FUNC(fsmount)
16
+{
17
+	printfd(tcp, tcp->u_arg[0]);
18
+	tprints(", ");
19
+
20
+	printflags(fsmount_flags, tcp->u_arg[1], "FSMOUNT_???");
21
+	tprints(", ");
22
+
23
+	printflags(mount_attr_flags, tcp->u_arg[2], "MOUNT_ATTR_???");
24
+
25
+	return RVAL_DECODED | RVAL_FD;
26
+}

+ 1
- 0
linux/syscallent-common.h View File

@@ -16,3 +16,4 @@
16 16
 [BASE_NR + 429] = { 5,	TD|TF,		SEN(move_mount),		"move_mount"		},
17 17
 [BASE_NR + 430] = { 2,	TD,		SEN(fsopen),			"fsopen"		},
18 18
 [BASE_NR + 431] = { 5,	TD|TF,		SEN(fsconfig),			"fsconfig"		},
19
+[BASE_NR + 432] = { 3,	TD,		SEN(fsmount),			"fsmount"		},

+ 1
- 0
pathtrace.c View File

@@ -341,6 +341,7 @@ pathtrace_match_set(struct tcb *tcp, struct path_set *set)
341 341
 	case SEN_eventfd2:
342 342
 	case SEN_eventfd:
343 343
 	case SEN_fanotify_init:
344
+	case SEN_fsmount:
344 345
 	case SEN_fsopen:
345 346
 	case SEN_inotify_init:
346 347
 	case SEN_inotify_init1:

+ 1
- 0
tests/.gitignore View File

@@ -91,6 +91,7 @@ flock
91 91
 fork-f
92 92
 fsconfig
93 93
 fsconfig-P
94
+fsmount
94 95
 fsopen
95 96
 fstat
96 97
 fstat-Xabbrev

+ 98
- 0
tests/fsmount.c View File

@@ -0,0 +1,98 @@
1
+/*
2
+ * Check decoding of fsmount syscall.
3
+ *
4
+ * Copyright (c) 2019 Dmitry V. Levin <ldv@altlinux.org>
5
+ * All rights reserved.
6
+ *
7
+ * SPDX-License-Identifier: GPL-2.0-or-later
8
+ */
9
+
10
+#include "tests.h"
11
+#include <asm/unistd.h>
12
+#include "scno.h"
13
+
14
+#ifdef __NR_fsmount
15
+
16
+# include <fcntl.h>
17
+# include <stdio.h>
18
+# include <stdint.h>
19
+# include <unistd.h>
20
+
21
+static const char *errstr;
22
+
23
+static long
24
+k_fsmount(const unsigned int fs_fd,
25
+	  const unsigned int flags,
26
+	  const unsigned int attr_flags)
27
+{
28
+	const kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
29
+	const kernel_ulong_t bad = (kernel_ulong_t) 0xbadc0dedbadc0dedULL;
30
+	const kernel_ulong_t arg1 = fill | fs_fd;
31
+	const kernel_ulong_t arg2 = fill | flags;
32
+	const kernel_ulong_t arg3 = fill | attr_flags;
33
+	const long rc = syscall(__NR_fsmount,
34
+				arg1, arg2, arg3, bad, bad, bad);
35
+	errstr = sprintrc(rc);
36
+	return rc;
37
+}
38
+
39
+int
40
+main(void)
41
+{
42
+	skip_if_unavailable("/proc/self/fd/");
43
+
44
+	static const char path[] = "/dev/full";
45
+        int fd = open(path, O_WRONLY);
46
+        if (fd < 0)
47
+                perror_msg_and_fail("open: %s", path);
48
+
49
+	struct {
50
+		unsigned int val;
51
+		const char *str;
52
+	} flags[] = {
53
+		{ ARG_STR(0) },
54
+		{ 1, "FSMOUNT_CLOEXEC" },
55
+		{ 2, "0x2 /* FSMOUNT_??? */" },
56
+		{ 0xfffffffe, "0xfffffffe /* FSMOUNT_??? */" },
57
+		{ -1, "FSMOUNT_CLOEXEC|0xfffffffe" }
58
+	},
59
+	attrs[] = {
60
+		{ ARG_STR(0) },
61
+		{ 1, "MOUNT_ATTR_RDONLY" },
62
+		{ 0x10, "MOUNT_ATTR_NOATIME" },
63
+		{ 0xbf, "MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV"
64
+			"|MOUNT_ATTR_NOEXEC|MOUNT_ATTR_NOATIME"
65
+			"|MOUNT_ATTR_STRICTATIME|MOUNT_ATTR_NODIRATIME" },
66
+		{ 0x40, "0x40 /* MOUNT_ATTR_??? */" },
67
+		{ 0xffffff40, "0xffffff40 /* MOUNT_ATTR_??? */" },
68
+		{ -1, "MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV"
69
+			"|MOUNT_ATTR_NOEXEC|MOUNT_ATTR_NOATIME"
70
+			"|MOUNT_ATTR_STRICTATIME|MOUNT_ATTR_NODIRATIME"
71
+			"|0xffffff40" }
72
+	};
73
+
74
+	for (unsigned int i = 0; i < ARRAY_SIZE(flags); ++i) {
75
+		for (unsigned int j = 0; j < ARRAY_SIZE(attrs); ++j) {
76
+			k_fsmount(-1, flags[i].val, attrs[j].val);
77
+			printf("fsmount(-1, %s, %s) = %s\n",
78
+			       flags[i].str, attrs[j].str, errstr);
79
+
80
+			k_fsmount(-100, flags[i].val, attrs[j].val);
81
+			printf("fsmount(-100, %s, %s) = %s\n",
82
+			       flags[i].str, attrs[j].str, errstr);
83
+
84
+			k_fsmount(fd, flags[i].val, attrs[j].val);
85
+			printf("fsmount(%d<%s>, %s, %s) = %s\n",
86
+			       fd, path, flags[i].str, attrs[j].str, errstr);
87
+		}
88
+	}
89
+
90
+	puts("+++ exited with 0 +++");
91
+	return 0;
92
+}
93
+
94
+#else
95
+
96
+SKIP_MAIN_UNDEFINED("__NR_fsmount")
97
+
98
+#endif

+ 1
- 0
tests/gen_tests.in View File

@@ -70,6 +70,7 @@ flock	-a19
70 70
 fork-f	-a26 -qq -f -e signal=none -e trace=chdir
71 71
 fsconfig	-s300 -y
72 72
 fsconfig-P	-s300 -y -P /dev/full -e trace=fsconfig
73
+fsmount	-a18 -y
73 74
 fsopen	-a35
74 75
 fstat	-a15 -v -P stat.sample
75 76
 fstat-Xabbrev -a15 -v -Xabbrev -P stat.sample -e trace=fstat

+ 1
- 0
tests/pure_executables.list View File

@@ -73,6 +73,7 @@ finit_module
73 73
 flock
74 74
 fsconfig
75 75
 fsconfig-P
76
+fsmount
76 77
 fsopen
77 78
 fstat
78 79
 fstat-Xabbrev

+ 1
- 0
xlat/fsmount_flags.in View File

@@ -0,0 +1 @@
1
+FSMOUNT_CLOEXEC	1

+ 7
- 0
xlat/mount_attr_flags.in View File

@@ -0,0 +1,7 @@
1
+MOUNT_ATTR_RDONLY	0x01
2
+MOUNT_ATTR_NOSUID	0x02
3
+MOUNT_ATTR_NODEV	0x04
4
+MOUNT_ATTR_NOEXEC	0x08
5
+MOUNT_ATTR_NOATIME	0x10
6
+MOUNT_ATTR_STRICTATIME	0x20
7
+MOUNT_ATTR_NODIRATIME	0x80

Loading…
Cancel
Save