Skip to contentSkip to conversation

selftests: seccomp: fix compile error seccomp_bpf

PATCH In review Anders Roxell 4 participants 8 messages Jan 5, 2018 – Jan 10, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: seccomp: fix compile error seccomp_bpf

aarch64-linux-gnu-gcc -Wl,-no-as-needed -Wall
-lpthread seccomp_bpf.c -o seccomp_bpf
seccomp_bpf.c: In function 'tracer_ptrace':
seccomp_bpf.c:1720:12: error: '__NR_open' undeclared
(first use in this function)
if (nr == __NR_open)

            ^~~~~~~~~

seccomp_bpf.c:1720:12: note: each undeclared identifier is reported
only once for each function it appears in
In file included from seccomp_bpf.c:48:0:
seccomp_bpf.c: In function 'TRACE_syscall_ptrace_syscall_dropped':
seccomp_bpf.c:1795:39: error: '__NR_open' undeclared
(first use in this function)

  EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_open));
                                       ^

open(2) is a legacy syscall, replaced with openat(2) since 2.6.16. Thus new architectures in the kernel, such as arm64, don't implement these legacy syscalls.

Signed-off-by Anders Roxell <anders.roxell at linaro.org>
---
 tools/testing/selftests/seccomp/seccomp_bpf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/seccomp/seccomp_bpf.c +2 -2
index 24dbf634e2dd..0b457e8e0f0c 100644
@@ -1717,7 +1717,7 @@ void tracer_ptrace(struct __test_metadata *_metadata, pid_t tracee,
 
 	if (nr == __NR_getpid)
 		change_syscall(_metadata, tracee, __NR_getppid);
-	if (nr == __NR_open)
+	if (nr == __NR_openat)
 		change_syscall(_metadata, tracee, -1);
 }
 
@@ -1792,7 +1792,7 @@ TEST_F(TRACE_syscall, ptrace_syscall_dropped)
 					   true);
 
 	/* Tracer should skip the open syscall, resulting in EPERM. */
-	EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_open));
+	EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_openat));
 }
 
 TEST_F(TRACE_syscall, syscall_allowed)
Signature · 6 lines
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tested-by on v1 1/1
#1 lore raw
Quoted 13 lines · Anders Roxell

aarch64-linux-gnu-gcc -Wl,-no-as-needed -Wall
-lpthread seccomp_bpf.c -o seccomp_bpf
seccomp_bpf.c: In function 'tracer_ptrace':
seccomp_bpf.c:1720:12: error: '__NR_open' undeclared
(first use in this function)
if (nr == __NR_open)

            ^~~~~~~~~

seccomp_bpf.c:1720:12: note: each undeclared identifier is reported
only once for each function it appears in
In file included from seccomp_bpf.c:48:0:
seccomp_bpf.c: In function 'TRACE_syscall_ptrace_syscall_dropped':
seccomp_bpf.c:1795:39: error: '__NR_open' undeclared
(first use in this function)

Quoted 7 lines
  EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_open));
                                       ^

open(2) is a legacy syscall, replaced with openat(2) since 2.6.16. Thus new architectures in the kernel, such as arm64, don't implement these legacy syscalls.

Signed-off-by Anders Roxell <anders.roxell at linaro.org>

Thanks for the patch Anders.
Tested-by: Naresh Kamboju <naresh.kamboju at linaro.org>

Quoted 27 lines
---
 tools/testing/selftests/seccomp/seccomp_bpf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/seccomp/seccomp_bpf.c +2 -3
index 24dbf634e2dd..0b457e8e0f0c 100644
@@ -1717,7 +1717,7 @@ void tracer_ptrace(struct __test_metadata *_metadata, pid_t tracee,
 
        if (nr == __NR_getpid)
                change_syscall(_metadata, tracee, __NR_getppid);
-       if (nr == __NR_open)
+       if (nr == __NR_openat)
                change_syscall(_metadata, tracee, -1);
 }
 
@@ -1792,7 +1792,7 @@ TEST_F(TRACE_syscall, ptrace_syscall_dropped)
                                           true);
 
        /* Tracer should skip the open syscall, resulting in EPERM. */
-       EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_open));
+       EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_openat));
 }
 
 TEST_F(TRACE_syscall, syscall_allowed)
--
Quoted 2 lines

2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 20 lines · Naresh Kamboju
Quoted 19 lines · Anders Roxell

aarch64-linux-gnu-gcc -Wl,-no-as-needed -Wall
-lpthread seccomp_bpf.c -o seccomp_bpf
seccomp_bpf.c: In function 'tracer_ptrace':
seccomp_bpf.c:1720:12: error: '__NR_open' undeclared
(first use in this function)
if (nr == __NR_open)

            ^~~~~~~~~

seccomp_bpf.c:1720:12: note: each undeclared identifier is reported
only once for each function it appears in
In file included from seccomp_bpf.c:48:0:
seccomp_bpf.c: In function 'TRACE_syscall_ptrace_syscall_dropped':
seccomp_bpf.c:1795:39: error: '__NR_open' undeclared
(first use in this function)

  EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_open));
                                       ^

open(2) is a legacy syscall, replaced with openat(2) since 2.6.16. Thus new architectures in the kernel, such as arm64, don't implement these legacy syscalls.

Quoted 4 lines
Quoted 1 line
Signed-off-by Anders Roxell <anders.roxell at linaro.org>

Thanks for the patch Anders.
Tested-by: Naresh Kamboju <naresh.kamboju at linaro.org>

Did something change recently? This has built fine on arm64 for a while -- at least since commit 256d0afb11d6 ("selftests/seccomp: build and pass on arm64").

-Kees

Quoted 30 lines
Quoted 30 lines
---
 tools/testing/selftests/seccomp/seccomp_bpf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/seccomp/seccomp_bpf.c +2 -3
index 24dbf634e2dd..0b457e8e0f0c 100644
@@ -1717,7 +1717,7 @@ void tracer_ptrace(struct __test_metadata *_metadata, pid_t tracee,
 
        if (nr == __NR_getpid)
                change_syscall(_metadata, tracee, __NR_getppid);
-       if (nr == __NR_open)
+       if (nr == __NR_openat)
                change_syscall(_metadata, tracee, -1);
 }
 
@@ -1792,7 +1792,7 @@ TEST_F(TRACE_syscall, ptrace_syscall_dropped)
                                           true);
 
        /* Tracer should skip the open syscall, resulting in EPERM. */
-       EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_open));
+       EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_openat));
 }
 
 TEST_F(TRACE_syscall, syscall_allowed)
--

2.11.0

Signature · 6 lines
Kees Cook
Pixel Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
Quoted 22 lines · Kees Cook
Quoted 20 lines · Naresh Kamboju
Quoted 19 lines · Anders Roxell

aarch64-linux-gnu-gcc -Wl,-no-as-needed -Wall
-lpthread seccomp_bpf.c -o seccomp_bpf
seccomp_bpf.c: In function 'tracer_ptrace':
seccomp_bpf.c:1720:12: error: '__NR_open' undeclared
(first use in this function)
if (nr == __NR_open)

            ^~~~~~~~~

seccomp_bpf.c:1720:12: note: each undeclared identifier is reported
only once for each function it appears in
In file included from seccomp_bpf.c:48:0:
seccomp_bpf.c: In function 'TRACE_syscall_ptrace_syscall_dropped':
seccomp_bpf.c:1795:39: error: '__NR_open' undeclared
(first use in this function)

  EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_open));
                                       ^

open(2) is a legacy syscall, replaced with openat(2) since 2.6.16. Thus new architectures in the kernel, such as arm64, don't implement these legacy syscalls.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Anders Roxell <anders.roxell at linaro.org>

Thanks for the patch Anders.
Tested-by: Naresh Kamboju <naresh.kamboju at linaro.org>

Did something change recently? This has built fine on arm64 for a while -- at least since commit 256d0afb11d6 ("selftests/seccomp: build and pass on arm64").

Ah, found it. I broke it in a33b2d0359a0! :) Shuah, can you take this please, with this tag added:

Fixes a33b2d0359a0 ("selftests/seccomp: Add tests for basic ptrace actions")

Thanks!

-Kees

Quoted 39 lines

-Kees

Quoted 26 lines
Quoted 26 lines
---
 tools/testing/selftests/seccomp/seccomp_bpf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/seccomp/seccomp_bpf.c +2 -2
index 24dbf634e2dd..0b457e8e0f0c 100644
@@ -1717,7 +1717,7 @@ void tracer_ptrace(struct __test_metadata *_metadata, pid_t tracee,
 
        if (nr == __NR_getpid)
                change_syscall(_metadata, tracee, __NR_getppid);
-       if (nr == __NR_open)
+       if (nr == __NR_openat)
                change_syscall(_metadata, tracee, -1);
 }
 
@@ -1792,7 +1792,7 @@ TEST_F(TRACE_syscall, ptrace_syscall_dropped)
                                           true);
 
        /* Tracer should skip the open syscall, resulting in EPERM. */
-       EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_open));
+       EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_openat));
 }
 
Quoted 4 lines
Quoted 4 lines
tools/testing/selftests/seccomp/seccomp_bpf.c +0 -1
 TEST_F(TRACE_syscall, syscall_allowed)
--

2.11.0

--
Kees Cook
Pixel Security

Signature · 6 lines
Kees Cook
Pixel Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw
Quoted 28 lines · Kees Cook
Quoted 27 lines · Kees Cook
Quoted 24 lines · Naresh Kamboju
Quoted 13 lines · Anders Roxell

aarch64-linux-gnu-gcc -Wl,-no-as-needed -Wall
-lpthread seccomp_bpf.c -o seccomp_bpf
seccomp_bpf.c: In function 'tracer_ptrace':
seccomp_bpf.c:1720:12: error: '__NR_open' undeclared
(first use in this function)
if (nr == __NR_open)

            ^~~~~~~~~

seccomp_bpf.c:1720:12: note: each undeclared identifier is reported
only once for each function it appears in
In file included from seccomp_bpf.c:48:0:
seccomp_bpf.c: In function 'TRACE_syscall_ptrace_syscall_dropped':
seccomp_bpf.c:1795:39: error: '__NR_open' undeclared
(first use in this function)

Quoted 7 lines
  EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_open));
                                       ^

open(2) is a legacy syscall, replaced with openat(2) since 2.6.16. Thus new architectures in the kernel, such as arm64, don't implement these legacy syscalls.

Signed-off-by Anders Roxell <anders.roxell at linaro.org>

Thanks for the patch Anders.
Tested-by: Naresh Kamboju <naresh.kamboju at linaro.org>

Quoted 8 lines
Quoted 3 lines

Did something change recently? This has built fine on arm64 for a while -- at least since commit 256d0afb11d6 ("selftests/seccomp: build and pass on arm64").

Ah, found it. I broke it in a33b2d0359a0! :) Shuah, can you take this please, with this tag added:

Fixes a33b2d0359a0 ("selftests/seccomp: Add tests for basic ptrace actions")

And Cc to stable, as this was broken in 4.14...

Cc stable at vger.kernel.org

-Kees

Signature · 6 lines
Kees Cook
Pixel Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#5 lore raw
Quoted 36 lines · Kees Cook
Quoted 35 lines · Kees Cook
Quoted 22 lines · Kees Cook
Quoted 20 lines · Naresh Kamboju
Quoted 19 lines · Anders Roxell

aarch64-linux-gnu-gcc -Wl,-no-as-needed -Wall
-lpthread seccomp_bpf.c -o seccomp_bpf
seccomp_bpf.c: In function 'tracer_ptrace':
seccomp_bpf.c:1720:12: error: '__NR_open' undeclared
(first use in this function)
if (nr == __NR_open)

            ^~~~~~~~~

seccomp_bpf.c:1720:12: note: each undeclared identifier is reported
only once for each function it appears in
In file included from seccomp_bpf.c:48:0:
seccomp_bpf.c: In function 'TRACE_syscall_ptrace_syscall_dropped':
seccomp_bpf.c:1795:39: error: '__NR_open' undeclared
(first use in this function)

  EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_open));
                                       ^

open(2) is a legacy syscall, replaced with openat(2) since 2.6.16. Thus new architectures in the kernel, such as arm64, don't implement these legacy syscalls.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Anders Roxell <anders.roxell at linaro.org>

Thanks for the patch Anders.
Tested-by: Naresh Kamboju <naresh.kamboju at linaro.org>

Did something change recently? This has built fine on arm64 for a while -- at least since commit 256d0afb11d6 ("selftests/seccomp: build and pass on arm64").

Ah, found it. I broke it in a33b2d0359a0! :) Shuah, can you take this please, with this tag added:

Quoted 8 lines
Quoted 1 line
Fixes a33b2d0359a0 ("selftests/seccomp: Add tests for basic ptrace actions")

And Cc to stable, as this was broken in 4.14...

Cc stable at vger.kernel.org

-Kees

Thanks Kees. Yes I will get this into 4.16-rc1. Okay to add your Acked-by I assume.

thanks,
-- Shuah
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Acked-by
#6 lore raw
Quoted 41 lines · Shuah Khan
Quoted 40 lines · Kees Cook
Quoted 28 lines · Kees Cook
Quoted 27 lines · Kees Cook
Quoted 24 lines · Naresh Kamboju
Quoted 13 lines · Anders Roxell

aarch64-linux-gnu-gcc -Wl,-no-as-needed -Wall
-lpthread seccomp_bpf.c -o seccomp_bpf
seccomp_bpf.c: In function 'tracer_ptrace':
seccomp_bpf.c:1720:12: error: '__NR_open' undeclared
(first use in this function)
if (nr == __NR_open)

            ^~~~~~~~~

seccomp_bpf.c:1720:12: note: each undeclared identifier is reported
only once for each function it appears in
In file included from seccomp_bpf.c:48:0:
seccomp_bpf.c: In function 'TRACE_syscall_ptrace_syscall_dropped':
seccomp_bpf.c:1795:39: error: '__NR_open' undeclared
(first use in this function)

Quoted 7 lines
  EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_open));
                                       ^

open(2) is a legacy syscall, replaced with openat(2) since 2.6.16. Thus new architectures in the kernel, such as arm64, don't implement these legacy syscalls.

Signed-off-by Anders Roxell <anders.roxell at linaro.org>

Thanks for the patch Anders.
Tested-by: Naresh Kamboju <naresh.kamboju at linaro.org>

Quoted 8 lines
Quoted 3 lines

Did something change recently? This has built fine on arm64 for a while -- at least since commit 256d0afb11d6 ("selftests/seccomp: build and pass on arm64").

Ah, found it. I broke it in a33b2d0359a0! :) Shuah, can you take this please, with this tag added:

Fixes a33b2d0359a0 ("selftests/seccomp: Add tests for basic ptrace actions")

And Cc to stable, as this was broken in 4.14...

Quoted 7 lines
Quoted 4 lines
Cc stable at vger.kernel.org

-Kees

Thanks Kees. Yes I will get this into 4.16-rc1. Okay to add your Acked-by I assume.

Yes, thanks! Here it is all together:

Fixes a33b2d0359a0 ("selftests/seccomp: Add tests for basic ptrace actions")
Cc stable at vger.kernel.org
Acked-by Kees Cook <keescook at chromium.org>

-Kees

Signature · 6 lines
Kees Cook
Pixel Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#7 lore raw
Quoted 50 lines · Kees Cook
Quoted 41 lines · Shuah Khan
Quoted 40 lines · Kees Cook
Quoted 28 lines · Kees Cook
Quoted 27 lines · Kees Cook
Quoted 24 lines · Naresh Kamboju
Quoted 13 lines · Anders Roxell

aarch64-linux-gnu-gcc -Wl,-no-as-needed -Wall
-lpthread seccomp_bpf.c -o seccomp_bpf
seccomp_bpf.c: In function 'tracer_ptrace':
seccomp_bpf.c:1720:12: error: '__NR_open' undeclared
(first use in this function)
if (nr == __NR_open)

            ^~~~~~~~~

seccomp_bpf.c:1720:12: note: each undeclared identifier is reported
only once for each function it appears in
In file included from seccomp_bpf.c:48:0:
seccomp_bpf.c: In function 'TRACE_syscall_ptrace_syscall_dropped':
seccomp_bpf.c:1795:39: error: '__NR_open' undeclared
(first use in this function)

Quoted 7 lines
  EXPECT_SYSCALL_RETURN(EPERM, syscall(__NR_open));
                                       ^

open(2) is a legacy syscall, replaced with openat(2) since 2.6.16. Thus new architectures in the kernel, such as arm64, don't implement these legacy syscalls.

Signed-off-by Anders Roxell <anders.roxell at linaro.org>

Thanks for the patch Anders.
Tested-by: Naresh Kamboju <naresh.kamboju at linaro.org>

Quoted 8 lines
Quoted 3 lines

Did something change recently? This has built fine on arm64 for a while -- at least since commit 256d0afb11d6 ("selftests/seccomp: build and pass on arm64").

Ah, found it. I broke it in a33b2d0359a0! :) Shuah, can you take this please, with this tag added:

Fixes a33b2d0359a0 ("selftests/seccomp: Add tests for basic ptrace actions")

And Cc to stable, as this was broken in 4.14...

Quoted 7 lines
Quoted 4 lines
Cc stable at vger.kernel.org

-Kees

Thanks Kees. Yes I will get this into 4.16-rc1. Okay to add your Acked-by I assume.

Quoted 9 lines

Yes, thanks! Here it is all together:

Fixes a33b2d0359a0 ("selftests/seccomp: Add tests for basic ptrace actions")
Cc stable at vger.kernel.org
Acked-by Kees Cook <keescook at chromium.org>

-Kees

Applied to linux-kselftest next for 4.16-rc1

thanks,
-- Shuah
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html