From: Michael Ellerman <mpe@ellerman.id.au>
To: Kees Cook <keescook@chromium.org>,
Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Cc: linuxppc-dev@lists.ozlabs.org, Shuah Khan <shuah@kernel.org>,
Oleg Nesterov <oleg@redhat.com>,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v2] selftests/seccomp: fix ptrace tests on powerpc
Date: Sun, 13 Sep 2020 17:35:29 +1000 [thread overview]
Message-ID: <87ft7mqgce.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <202009111550.07017FE49@keescook>
Kees Cook <keescook@chromium.org> writes:
> On Fri, Sep 11, 2020 at 03:10:12PM -0300, Thadeu Lima de Souza Cascardo wrote:
...
>> diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
>> index 7a6d40286a42..0ddc0846e9c0 100644
>> --- a/tools/testing/selftests/seccomp/seccomp_bpf.c
>> +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
>> @@ -1916,10 +1957,15 @@ void tracer_ptrace(struct __test_metadata *_metadata, pid_t tracee,
>> EXPECT_EQ(entry ? PTRACE_EVENTMSG_SYSCALL_ENTRY
>> : PTRACE_EVENTMSG_SYSCALL_EXIT, msg);
>>
>> - if (!entry)
>> + if (!entry && !variant)
>> return;
>>
>> - nr = get_syscall(_metadata, tracee);
>> + if (entry)
>> + nr = get_syscall(_metadata, tracee);
>> + else if (variant)
>> + nr = variant->syscall_nr;
>> + if (variant)
>> + variant->syscall_nr = nr;
>
> So, to be clear this is _only_ an issue for the ptrace side of things,
> yes? i.e. seccomp's setting of the return value will correct stick?
Yes. There's a comment which (hopefully) explains the difference here:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/kernel/ptrace/ptrace.c?commit=ab29a807a7ddaa7c84d2f4cb8d29e74e33759072#n239
Which says:
static int do_seccomp(struct pt_regs *regs)
{
if (!test_thread_flag(TIF_SECCOMP))
return 0;
/*
* The ABI we present to seccomp tracers is that r3 contains
* the syscall return value and orig_gpr3 contains the first
* syscall parameter. This is different to the ptrace ABI where
* both r3 and orig_gpr3 contain the first syscall parameter.
*/
regs->gpr[3] = -ENOSYS;
cheers
prev parent reply other threads:[~2020-09-13 7:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-11 18:10 [PATCH v2] selftests/seccomp: fix ptrace tests on powerpc Thadeu Lima de Souza Cascardo
2020-09-11 19:06 ` Shuah Khan
2020-09-11 22:55 ` Kees Cook
2020-09-13 7:35 ` Michael Ellerman [this message]
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=87ft7mqgce.fsf@mpe.ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=cascardo@canonical.com \
--cc=keescook@chromium.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=oleg@redhat.com \
--cc=shuah@kernel.org \
/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).