diff options
| author | Lukas Berk <lberk@redhat.com> | 2015-02-18 15:26:07 -0500 |
|---|---|---|
| committer | Lukas Berk <lberk@redhat.com> | 2015-02-18 15:26:07 -0500 |
| commit | bf16266782e1f2588b519a50d9684279d4e21036 (patch) | |
| tree | a973df86d5fe53137864ad340a5f2815033f7e21 | |
| parent | release 2.7 dating in .spec & NEWS (diff) | |
Linux 3.19 added the execveat syscall, adding tapset supportrelease-2.7
tapset/linux/nd_syscalls.stp - no debuginfo tapset tapset/linux/syscalls.stp - regular tapset testsuite/buildok/nd_syscalls-detailed.stp - update no debuginfo testcase testsuite/buildok/syscalls-detailed.stp - update testcase testsuite/systemtap.syscall/execveat.c - new syscall testcase
| -rw-r--r-- | tapset/linux/nd_syscalls.stp | 42 | ||||
| -rw-r--r-- | tapset/linux/syscalls.stp | 44 | ||||
| -rwxr-xr-x | testsuite/buildok/nd_syscalls-detailed.stp | 11 | ||||
| -rwxr-xr-x | testsuite/buildok/syscalls-detailed.stp | 10 | ||||
| -rw-r--r-- | testsuite/systemtap.syscall/execveat.c | 29 |
5 files changed, 136 insertions, 0 deletions
diff --git a/tapset/linux/nd_syscalls.stp b/tapset/linux/nd_syscalls.stp index 307242150..6c1d452d1 100644 --- a/tapset/linux/nd_syscalls.stp +++ b/tapset/linux/nd_syscalls.stp | |||
| @@ -1164,6 +1164,30 @@ probe nd_syscall.execve.return = kprobe.function("do_execve").return | |||
| 1164 | } | 1164 | } |
| 1165 | %) | 1165 | %) |
| 1166 | 1166 | ||
| 1167 | # execveat ______________________________________________ | ||
| 1168 | # SYSCALL_DEFINE5(execveat, | ||
| 1169 | # int, fd, const char __user *, filename, | ||
| 1170 | # const char __user *const __user *, argv, | ||
| 1171 | # const char __user *const __user *, envp, | ||
| 1172 | # int, flags) | ||
| 1173 | # | ||
| 1174 | probe nd_syscall.execveat = kprobe.function("do_execveat").call ? | ||
| 1175 | { | ||
| 1176 | name = "execveat" | ||
| 1177 | fd = __int32(1) | ||
| 1178 | fd_str = _dfd_str(fd) | ||
| 1179 | filename = user_string_quoted(pointer_arg(2)) | ||
| 1180 | args = __get_argv(pointer_arg(3), 0) | ||
| 1181 | flags = int_arg(5) | ||
| 1182 | flags_str = _at_flag_str(flags) | ||
| 1183 | argstr = sprintf("%s %s %s %s", fd_str, filename, args, flags_str) | ||
| 1184 | } | ||
| 1185 | probe nd_syscall.execveat.return = kprobe.function("do_execveat").return ? | ||
| 1186 | { | ||
| 1187 | name = "execveat" | ||
| 1188 | retstr = returnstr(1) | ||
| 1189 | } | ||
| 1190 | |||
| 1167 | %( kernel_v >= "3.7" %? | 1191 | %( kernel_v >= "3.7" %? |
| 1168 | # In kernels >= 3.7, compat_sys_execve() has been moved to generic | 1192 | # In kernels >= 3.7, compat_sys_execve() has been moved to generic |
| 1169 | # code, so we can use it with confidence. | 1193 | # code, so we can use it with confidence. |
| @@ -1210,6 +1234,24 @@ probe nd_syscall.compat_execve.return = | |||
| 1210 | } | 1234 | } |
| 1211 | %) | 1235 | %) |
| 1212 | 1236 | ||
| 1237 | probe nd_syscall.compat_execveat = kprobe.function("compat_do_execveat").call ? | ||
| 1238 | { | ||
| 1239 | name = "compat_execveat" | ||
| 1240 | fd = __int32(1) | ||
| 1241 | fd_str = _dfd_str(fd) | ||
| 1242 | filename = user_string_quoted(pointer_arg(2)) | ||
| 1243 | args = __get_argv(pointer_arg(3), 0) | ||
| 1244 | flags = int32_arg(5) | ||
| 1245 | flags_str = _at_flag_str(flags) | ||
| 1246 | argstr = sprintf("%s %s %s %s", fd_str, filename, args, flags_str) | ||
| 1247 | |||
| 1248 | } | ||
| 1249 | probe nd_syscall.compat_execveat.return = kprobe.function("compat_do_execveat").return ? | ||
| 1250 | { | ||
| 1251 | name = "compat_execveat" | ||
| 1252 | retstr = returnstr(1) | ||
| 1253 | } | ||
| 1254 | |||
| 1213 | # exit _______________________________________________________ | 1255 | # exit _______________________________________________________ |
| 1214 | # long sys_exit(int error_code) | 1256 | # long sys_exit(int error_code) |
| 1215 | probe nd_syscall.exit = kprobe.function("sys_exit").call | 1257 | probe nd_syscall.exit = kprobe.function("sys_exit").call |
diff --git a/tapset/linux/syscalls.stp b/tapset/linux/syscalls.stp index c06c96f40..ca3168222 100644 --- a/tapset/linux/syscalls.stp +++ b/tapset/linux/syscalls.stp | |||
| @@ -1069,6 +1069,32 @@ probe syscall.execve.return = kernel.function("do_execve").return | |||
| 1069 | } | 1069 | } |
| 1070 | %) | 1070 | %) |
| 1071 | 1071 | ||
| 1072 | # execveat ______________________________________________ | ||
| 1073 | # SYSCALL_DEFINE5(execveat, | ||
| 1074 | # int, fd, const char __user *, filename, | ||
| 1075 | # const char __user *const __user *, argv, | ||
| 1076 | # const char __user *const __user *, envp, | ||
| 1077 | # int, flags) | ||
| 1078 | # | ||
| 1079 | probe syscall.execveat = kernel.function("sys_execveat").call ? | ||
| 1080 | { | ||
| 1081 | name = "execveat" | ||
| 1082 | fd = __int32($fd) | ||
| 1083 | fd_str = _dfd_str(__int32($fd)) | ||
| 1084 | filename = user_string_quoted(@__pointer($filename)) | ||
| 1085 | flags = int_arg($flags) | ||
| 1086 | flags_str = _at_flag_str(__int32($flags)) | ||
| 1087 | __argv = @choose_defined($__argv, $argv) | ||
| 1088 | args = __get_argv(__argv, 0) | ||
| 1089 | argstr = sprintf("%s %s %s %s", fd_str, filename, __get_argv(__argv, 1), flags_str) | ||
| 1090 | } | ||
| 1091 | |||
| 1092 | probe syscall.execveat.return = kernel.function("sys_execveat").return ? | ||
| 1093 | { | ||
| 1094 | name = "execveat" | ||
| 1095 | retstr = return_str(1, $return) | ||
| 1096 | } | ||
| 1097 | |||
| 1072 | %( kernel_v >= "3.7" %? | 1098 | %( kernel_v >= "3.7" %? |
| 1073 | # In kernels >= 3.7, compat_sys_execve() has been moved to generic | 1099 | # In kernels >= 3.7, compat_sys_execve() has been moved to generic |
| 1074 | # code, so we can use it with confidence. | 1100 | # code, so we can use it with confidence. |
| @@ -1116,6 +1142,24 @@ probe syscall.compat_execve.return = | |||
| 1116 | retstr = return_str(1, $return) | 1142 | retstr = return_str(1, $return) |
| 1117 | } | 1143 | } |
| 1118 | %) | 1144 | %) |
| 1145 | probe syscall.compat_execveat = kernel.function("compat_sys_execveat").call ? | ||
| 1146 | { | ||
| 1147 | name = "compat_execveat" | ||
| 1148 | fd = __int32($fd) | ||
| 1149 | fd_str = _dfd_str(__int32($fd)) | ||
| 1150 | filename = user_string_quoted(@__pointer($filename)) | ||
| 1151 | flags = int_arg($flags) | ||
| 1152 | flags_str = _at_flag_str(__int32($flags)) | ||
| 1153 | __argv = @choose_defined($__argv, $argv) | ||
| 1154 | args = __get_argv(__argv, 0) | ||
| 1155 | argstr = sprintf("%s %s %s %s", fd_str, filename, __get_argv(__argv, 1), flags_str) | ||
| 1156 | } | ||
| 1157 | |||
| 1158 | probe syscall.compat_execveat.return = kernel.function("compat_sys_execveat").return ? | ||
| 1159 | { | ||
| 1160 | name = "compat_execveat" | ||
| 1161 | retstr = return_str(1, $return) | ||
| 1162 | } | ||
| 1119 | 1163 | ||
| 1120 | # exit _______________________________________________________ | 1164 | # exit _______________________________________________________ |
| 1121 | # long sys_exit(int error_code) | 1165 | # long sys_exit(int error_code) |
diff --git a/testsuite/buildok/nd_syscalls-detailed.stp b/testsuite/buildok/nd_syscalls-detailed.stp index cd39032ff..e759d1d5f 100755 --- a/testsuite/buildok/nd_syscalls-detailed.stp +++ b/testsuite/buildok/nd_syscalls-detailed.stp | |||
| @@ -342,6 +342,17 @@ probe nd_syscall.execve.return, nd_syscall.compat_execve.return ? | |||
| 342 | printf("%s, %s\n", name, retstr) | 342 | printf("%s, %s\n", name, retstr) |
| 343 | } | 343 | } |
| 344 | 344 | ||
| 345 | probe nd_syscall.execveat, nd_syscall.compat_execveat ? | ||
| 346 | { | ||
| 347 | printf("%s, %s\n", name, argstr) | ||
| 348 | printf("%d, %s, %s, %d(%s), %s\n", fd, fd_str, filename, flags, flags_str, args) | ||
| 349 | } | ||
| 350 | |||
| 351 | probe nd_syscall.execveat.return, nd_syscall.compat_execveat.return ? | ||
| 352 | { | ||
| 353 | printf("%s, %s\n", name, retstr) | ||
| 354 | } | ||
| 355 | |||
| 345 | probe nd_syscall.exit | 356 | probe nd_syscall.exit |
| 346 | { | 357 | { |
| 347 | printf("%s, %s\n", name, argstr) | 358 | printf("%s, %s\n", name, argstr) |
diff --git a/testsuite/buildok/syscalls-detailed.stp b/testsuite/buildok/syscalls-detailed.stp index 85635e417..f3f3ddcee 100755 --- a/testsuite/buildok/syscalls-detailed.stp +++ b/testsuite/buildok/syscalls-detailed.stp | |||
| @@ -342,6 +342,16 @@ probe syscall.execve.return, syscall.compat_execve.return ? | |||
| 342 | printf("%s, %s\n", name, retstr) | 342 | printf("%s, %s\n", name, retstr) |
| 343 | } | 343 | } |
| 344 | 344 | ||
| 345 | probe syscall.execveat, syscall.compat_execveat ? | ||
| 346 | { | ||
| 347 | printf("%s, %s\n", name, argstr) | ||
| 348 | printf("%d, %s, %s, %d(%s), %s\n", fd, fd_str, filename, flags, flags_str, args) | ||
| 349 | } | ||
| 350 | |||
| 351 | probe syscall.execveat.return, syscall.compat_execveat.return ? | ||
| 352 | { | ||
| 353 | printf("%s, %s\n", name, retstr) | ||
| 354 | } | ||
| 345 | probe syscall.exit | 355 | probe syscall.exit |
| 346 | { | 356 | { |
| 347 | printf("%s, %s\n", name, argstr) | 357 | printf("%s, %s\n", name, argstr) |
diff --git a/testsuite/systemtap.syscall/execveat.c b/testsuite/systemtap.syscall/execveat.c new file mode 100644 index 000000000..fa8c63038 --- /dev/null +++ b/testsuite/systemtap.syscall/execveat.c | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | #include <sys/syscall.h> | ||
| 2 | #include <fcntl.h> | ||
| 3 | #include <unistd.h> | ||
| 4 | #if !defined(SYS_execveat) && defined(__NR_execveat) | ||
| 5 | #define SYS_execveat __NR_execveat | ||
| 6 | #endif | ||
| 7 | |||
| 8 | int main() { | ||
| 9 | #ifdef SYS_execveat | ||
| 10 | syscall(SYS_execveat, -1, "/bin/true", -1L, NULL, NULL); | ||
| 11 | //staptest// execveat (-1 "/bin/true" 0x0) = -NNNN (EFAULT) | ||
| 12 | syscall(SYS_execveat, -1, "/bin/true", NULL, -1L, NULL); | ||
| 13 | //staptest// execveat (-1 "/bin/true" 0x0) = -NNNN (EFAULT) | ||
| 14 | syscall(SYS_execveat, -1, "/bin/true", NULL, NULL, -1); | ||
| 15 | //staptest// execveat (-1 "/bin/true" AT_SYMLINK_NOFOLLOW|AT_REMOVEDIR|AT_SYMLINK_FOLLOW|AT_NO_AUTOMOUNT|AT_EMPTY_PATH|XXXX) = -NNNN | ||
| 16 | syscall(SYS_execveat, AT_FDCWD, "", NULL, NULL, NULL); | ||
| 17 | //staptest// execveat (AT_FDCWD "" 0x0) = -NNNN (ENOENT) | ||
| 18 | syscall(SYS_execveat, -1, -1L, NULL, NULL, NULL); | ||
| 19 | #if __WORDSIZE == 64 | ||
| 20 | //staptest// execveat (-1 [16]?[f]+ 0x0) = -NNNN (EFAULT) | ||
| 21 | #else | ||
| 22 | //staptest// execveat (-1 [8]?[f]+ 0x0) = -NNNN (EFAULT) | ||
| 23 | #endif | ||
| 24 | syscall(SYS_execveat, -1, "/bin/true", NULL, NULL, NULL); | ||
| 25 | //staptest// execveat (-1 "/bin/true" 0x0) = NNNN | ||
| 26 | #endif | ||
| 27 | return 0; | ||
| 28 | } | ||
| 29 | |||
