| @@ -1210,6 +1210,10 @@ TEST_F(TRACE_poke, getpid_runs_normally) · 1209 unmodified lines |
| 1210 | 1210 | # define ARCH_REGS struct pt_regs |
| 1211 | 1211 | # define SYSCALL_NUM gpr[0] |
| 1212 | 1212 | # define SYSCALL_RET gpr[3] |
| 1213 | +#elif defined(__s390__) |
| 1214 | +# define ARCH_REGS s390_regs |
| 1215 | +# define SYSCALL_NUM gprs[2] |
| 1216 | +# define SYSCALL_RET gprs[2] |
| 1213 | 1217 | #else |
| 1214 | 1218 | # error "Do not know how to find your architecture's registers and syscalls" |
| 1215 | 1219 | #endif |
| @@ -1243,7 +1247,8 @@ void change_syscall(struct __test_metadata *_metadata, · 27 unmodified lines |
| 1243 | 1247 | ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, &iov); |
| 1244 | 1248 | EXPECT_EQ(0, ret); |
| 1245 | 1249 | |
| 1246 | | −#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || defined(__powerpc__) |
| 1250 | +#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || \ |
| 1251 | + defined(__powerpc__) || defined(__s390__) |
| 1247 | 1252 | { |
| 1248 | 1253 | regs.SYSCALL_NUM = syscall; |
| 1249 | 1254 | } |
| @@ -1281,17 +1286,21 @@ void tracer_syscall(struct __test_metadata *_metadata, pid_t tracee, · 31 unmodified lines |
| 1281 | 1286 | ret = ptrace(PTRACE_GETEVENTMSG, tracee, NULL, &msg); |
| 1282 | 1287 | EXPECT_EQ(0, ret); |
| 1283 | 1288 | |
| 1289 | + /* Validate and take action on expected syscalls. */ |
| 1284 | 1290 | switch (msg) { |
| 1285 | 1291 | case 0x1002: |
| 1286 | 1292 | /* change getpid to getppid. */ |
| 1293 | + EXPECT_EQ(__NR_getpid, get_syscall(_metadata, tracee)); |
| 1287 | 1294 | change_syscall(_metadata, tracee, __NR_getppid); |
| 1288 | 1295 | break; |
| 1289 | 1296 | case 0x1003: |
| 1290 | 1297 | /* skip gettid. */ |
| 1298 | + EXPECT_EQ(__NR_gettid, get_syscall(_metadata, tracee)); |
| 1291 | 1299 | change_syscall(_metadata, tracee, -1); |
| 1292 | 1300 | break; |
| 1293 | 1301 | case 0x1004: |
| 1294 | 1302 | /* do nothing (allow getppid) */ |
| 1303 | + EXPECT_EQ(__NR_getppid, get_syscall(_metadata, tracee)); |
| 1295 | 1304 | break; |
| 1296 | 1305 | default: |
| 1297 | 1306 | EXPECT_EQ(0, msg) { |
| @@ -1409,6 +1418,8 @@ TEST_F(TRACE_syscall, syscall_dropped) · 111 unmodified lines |
| 1409 | 1418 | # define __NR_seccomp 277 |
| 1410 | 1419 | # elif defined(__powerpc__) |
| 1411 | 1420 | # define __NR_seccomp 358 |
| 1421 | +# elif defined(__s390__) |
| 1422 | +# define __NR_seccomp 348 |
| 1412 | 1423 | # else |
| 1413 | 1424 | # warning "seccomp syscall number unknown for this architecture" |
| 1414 | 1425 | # define __NR_seccomp 0xffff |
| @@ -1453,6 +1464,9 @@ TEST(seccomp_syscall) · 38 unmodified lines |
| 1453 | 1464 | |
| 1454 | 1465 | /* Reject insane operation. */ |
| 1455 | 1466 | ret = seccomp(-1, 0, &prog); |
| 1467 | + ASSERT_NE(ENOSYS, errno) { |
| 1468 | + TH_LOG("Kernel does not support seccomp syscall!"); |
| 1469 | + } |
| 1456 | 1470 | EXPECT_EQ(EINVAL, errno) { |
| 1457 | 1471 | TH_LOG("Did not reject crazy op value!"); |
| 1458 | 1472 | } |
| @@ -1501,6 +1515,9 @@ TEST(seccomp_syscall_mode_lock) · 42 unmodified lines |
| 1501 | 1515 | } |
| 1502 | 1516 | |
| 1503 | 1517 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog); |
| 1518 | + ASSERT_NE(ENOSYS, errno) { |
| 1519 | + TH_LOG("Kernel does not support seccomp syscall!"); |
| 1520 | + } |
| 1504 | 1521 | EXPECT_EQ(0, ret) { |
| 1505 | 1522 | TH_LOG("Could not install filter!"); |
| 1506 | 1523 | } |
| @@ -1535,6 +1552,9 @@ TEST(TSYNC_first) · 28 unmodified lines |
| 1535 | 1552 | |
| 1536 | 1553 | ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC, |
| 1537 | 1554 | &prog); |
| 1555 | + ASSERT_NE(ENOSYS, errno) { |
| 1556 | + TH_LOG("Kernel does not support seccomp syscall!"); |
| 1557 | + } |
| 1538 | 1558 | EXPECT_EQ(0, ret) { |
| 1539 | 1559 | TH_LOG("Could not install initial filter with TSYNC!"); |
| 1540 | 1560 | } |
| @@ -1694,6 +1714,9 @@ TEST_F(TSYNC, siblings_fail_prctl) · 153 unmodified lines |
| 1694 | 1714 | |
| 1695 | 1715 | /* Check prctl failure detection by requesting sib 0 diverge. */ |
| 1696 | 1716 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog); |
| 1717 | + ASSERT_NE(ENOSYS, errno) { |
| 1718 | + TH_LOG("Kernel does not support seccomp syscall!"); |
| 1719 | + } |
| 1697 | 1720 | ASSERT_EQ(0, ret) { |
| 1698 | 1721 | TH_LOG("setting filter failed"); |
| 1699 | 1722 | } |
| @@ -1731,6 +1754,9 @@ TEST_F(TSYNC, two_siblings_with_ancestor) · 31 unmodified lines |
| 1731 | 1754 | } |
| 1732 | 1755 | |
| 1733 | 1756 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &self->root_prog); |
| 1757 | + ASSERT_NE(ENOSYS, errno) { |
| 1758 | + TH_LOG("Kernel does not support seccomp syscall!"); |
| 1759 | + } |
| 1734 | 1760 | ASSERT_EQ(0, ret) { |
| 1735 | 1761 | TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!"); |
| 1736 | 1762 | } |
| @@ -1805,6 +1831,9 @@ TEST_F(TSYNC, two_siblings_with_no_filter) · 68 unmodified lines |
| 1805 | 1831 | |
| 1806 | 1832 | ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FLAG_FILTER_TSYNC, |
| 1807 | 1833 | &self->apply_prog); |
| 1834 | + ASSERT_NE(ENOSYS, errno) { |
| 1835 | + TH_LOG("Kernel does not support seccomp syscall!"); |
| 1836 | + } |
| 1808 | 1837 | ASSERT_EQ(0, ret) { |
| 1809 | 1838 | TH_LOG("Could install filter on all threads!"); |
| 1810 | 1839 | } |
| @@ -1833,6 +1862,9 @@ TEST_F(TSYNC, two_siblings_with_one_divergence) · 22 unmodified lines |
| 1833 | 1862 | } |
| 1834 | 1863 | |
| 1835 | 1864 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &self->root_prog); |
| 1865 | + ASSERT_NE(ENOSYS, errno) { |
| 1866 | + TH_LOG("Kernel does not support seccomp syscall!"); |
| 1867 | + } |
| 1836 | 1868 | ASSERT_EQ(0, ret) { |
| 1837 | 1869 | TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!"); |
| 1838 | 1870 | } |
| @@ -1890,6 +1922,9 @@ TEST_F(TSYNC, two_siblings_not_under_filter) · 51 unmodified lines |
| 1890 | 1922 | } |
| 1891 | 1923 | |
| 1892 | 1924 | ret = seccomp(SECCOMP_SET_MODE_FILTER, 0, &self->root_prog); |
| 1925 | + ASSERT_NE(ENOSYS, errno) { |
| 1926 | + TH_LOG("Kernel does not support seccomp syscall!"); |
| 1927 | + } |
| 1893 | 1928 | ASSERT_EQ(0, ret) { |
| 1894 | 1929 | TH_LOG("Kernel does not support SECCOMP_SET_MODE_FILTER!"); |
| 1895 | 1930 | } |