]> granicus.if.org Git - strace/commitdiff
filter_seccomp: fix build for no-MMU targets
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 4 Oct 2019 13:16:33 +0000 (13:16 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 4 Oct 2019 21:58:20 +0000 (21:58 +0000)
Avoid unsupported fork() call on no-MMU Linux systems to fix
the following link error:

ld: strace-filter_seccomp.o: in function `check_seccomp_filter':
filter_seccomp.c:(.text+0x39a): undefined reference to `fork'
collect2: error: ld returned 1 exit status

* filter_seccomp.c (__gcov_flush, check_seccomp_order_do_child,
check_seccomp_order_tracer): Move under HAVE_FORK guard.
(check_seccomp_order): Move fork code under HAVE_FORK guard.
(check_seccomp_filter_properties): Do not check for NOMMU_SYSTEM.
* NEWS: Mention this fix.

Reported-and-tested-by: Baruch Siach <baruch@tkos.co.il>
Fixes: v5.3~7 "Introduce seccomp-assisted syscall filtering"
NEWS
filter_seccomp.c

diff --git a/NEWS b/NEWS
index ce1c65a2f50828579b26b26237144ada56efff03..7c687710cc16d356fbebf4df9339098131d70aa7 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,9 @@
 Noteworthy changes in release ?.? (????-??-??)
 ==============================================
 
+* Bug fixes
+  * Fixed build on no-MMU architectures.
+
 Noteworthy changes in release 5.3 (2019-09-25)
 ==============================================
 
index fc582654b7acfab0096f17c2250088bfb8c7928e..4b4c51fbe0a8a54ffc3fb7d4fc6eaa92a471ac3c 100644 (file)
@@ -59,9 +59,11 @@ static const struct audit_arch_t audit_arch_vec[SUPPORTED_PERSONALITIES] = {
 # endif
 };
 
-# ifdef ENABLE_COVERAGE_GCOV
+# ifdef HAVE_FORK
+
+#  ifdef ENABLE_COVERAGE_GCOV
 extern void __gcov_flush(void);
-# endif
+#  endif
 
 static void ATTRIBUTE_NORETURN
 check_seccomp_order_do_child(void)
@@ -91,9 +93,9 @@ check_seccomp_order_do_child(void)
                perror_func_msg_and_die("PTRACE_TRACEME");
        }
 
-# ifdef ENABLE_COVERAGE_GCOV
+#  ifdef ENABLE_COVERAGE_GCOV
        __gcov_flush();
-# endif
+#  endif
 
        kill(pid, SIGSTOP);
        syscall(__NR_gettid);
@@ -223,12 +225,15 @@ check_seccomp_order_tracer(int pid)
 
        return pid;
 }
+# endif /* HAVE_FORK */
 
 static void
 check_seccomp_order(void)
 {
        seccomp_filtering = false;
 
+       /* NOMMU provides no forks necessary for the test.  */
+# ifdef HAVE_FORK
        int pid = fork();
        if (pid < 0) {
                perror_func_msg("fork");
@@ -248,6 +253,7 @@ check_seccomp_order(void)
                        break;
                }
        }
+# endif /* HAVE_FORK */
 }
 
 static bool
@@ -340,11 +346,6 @@ check_bpf_program_size(void)
 static void
 check_seccomp_filter_properties(void)
 {
-       if (NOMMU_SYSTEM) {
-               seccomp_filtering = false;
-               return;
-       }
-
        int rc = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, 0, 0);
        seccomp_filtering = rc < 0 && errno != EINVAL;
        if (!seccomp_filtering)