linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Shuah Khan <shuah@kernel.org>
Cc: Tycho Andersen <tycho@tycho.ws>,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	Alakesh Haloi <alakesh.haloi@gmail.com>
Subject: Re: [PATCH] selftests/seccomp: fix build on older kernels
Date: Thu, 29 Aug 2019 10:06:06 -0700	[thread overview]
Message-ID: <201908291003.005EB96606@keescook> (raw)
In-Reply-To: <20190826144302.7745-1-tycho@tycho.ws>

On Mon, Aug 26, 2019 at 08:43:02AM -0600, Tycho Andersen wrote:
> The seccomp selftest goes to some length to build against older kernel
> headers, viz. all the #ifdefs at the beginning of the file. 201766a20e30
> ("ptrace: add PTRACE_GET_SYSCALL_INFO request") introduces some additional
> macros, but doesn't do the #ifdef dance. Let's add that dance here to
> avoid:
> 
> gcc -Wl,-no-as-needed -Wall  seccomp_bpf.c -lpthread -o seccomp_bpf
> In file included from seccomp_bpf.c:51:
> seccomp_bpf.c: In function ‘tracer_ptrace’:
> seccomp_bpf.c:1787:20: error: ‘PTRACE_EVENTMSG_SYSCALL_ENTRY’ undeclared (first use in this function); did you mean ‘PTRACE_EVENT_CLONE’?
>   EXPECT_EQ(entry ? PTRACE_EVENTMSG_SYSCALL_ENTRY
>                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../kselftest_harness.h:608:13: note: in definition of macro ‘__EXPECT’
>   __typeof__(_expected) __exp = (_expected); \
>              ^~~~~~~~~
> seccomp_bpf.c:1787:2: note: in expansion of macro ‘EXPECT_EQ’
>   EXPECT_EQ(entry ? PTRACE_EVENTMSG_SYSCALL_ENTRY
>   ^~~~~~~~~
> seccomp_bpf.c:1787:20: note: each undeclared identifier is reported only once for each function it appears in
>   EXPECT_EQ(entry ? PTRACE_EVENTMSG_SYSCALL_ENTRY
>                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../kselftest_harness.h:608:13: note: in definition of macro ‘__EXPECT’
>   __typeof__(_expected) __exp = (_expected); \
>              ^~~~~~~~~
> seccomp_bpf.c:1787:2: note: in expansion of macro ‘EXPECT_EQ’
>   EXPECT_EQ(entry ? PTRACE_EVENTMSG_SYSCALL_ENTRY
>   ^~~~~~~~~
> seccomp_bpf.c:1788:6: error: ‘PTRACE_EVENTMSG_SYSCALL_EXIT’ undeclared (first use in this function); did you mean ‘PTRACE_EVENT_EXIT’?
>     : PTRACE_EVENTMSG_SYSCALL_EXIT, msg);
>       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../kselftest_harness.h:608:13: note: in definition of macro ‘__EXPECT’
>   __typeof__(_expected) __exp = (_expected); \
>              ^~~~~~~~~
> seccomp_bpf.c:1787:2: note: in expansion of macro ‘EXPECT_EQ’
>   EXPECT_EQ(entry ? PTRACE_EVENTMSG_SYSCALL_ENTRY
>   ^~~~~~~~~
> make: *** [Makefile:12: seccomp_bpf] Error 1
> 
> Signed-off-by: Tycho Andersen <tycho@tycho.ws>
> Fixes: 201766a20e30 ("ptrace: add PTRACE_GET_SYSCALL_INFO request")

Acked-by: Kees Cook <keescook@chromium.org>

Alakesh Haloi also sent a fix[1] for this. I prefer Tycho's solution
(one #ifndef and a Fixes line). Shuah, can you please apply this?

Thanks!

-Kees

[1] https://lore.kernel.org/lkml/20190822215823.GA11292@ip-172-31-44-144.us-west-2.compute.internal

> ---
>  tools/testing/selftests/seccomp/seccomp_bpf.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
> index 6ef7f16c4cf5..7f8b5c8982e3 100644
> --- a/tools/testing/selftests/seccomp/seccomp_bpf.c
> +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
> @@ -199,6 +199,11 @@ struct seccomp_notif_sizes {
>  };
>  #endif
>  
> +#ifndef PTRACE_EVENTMSG_SYSCALL_ENTRY
> +#define PTRACE_EVENTMSG_SYSCALL_ENTRY	1
> +#define PTRACE_EVENTMSG_SYSCALL_EXIT	2
> +#endif
> +
>  #ifndef seccomp
>  int seccomp(unsigned int op, unsigned int flags, void *args)
>  {
> -- 
> 2.20.1
> 

-- 
Kees Cook

  reply	other threads:[~2019-08-29 17:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-26 14:43 [PATCH] selftests/seccomp: fix build on older kernels Tycho Andersen
2019-08-29 17:06 ` Kees Cook [this message]
2019-08-30  0:45   ` shuah
2019-08-30 15:19     ` shuah
2019-08-30 15:31       ` Tycho Andersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201908291003.005EB96606@keescook \
    --to=keescook@chromium.org \
    --cc=alakesh.haloi@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=tycho@tycho.ws \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).