From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EB8FC433E0 for ; Mon, 27 Jul 2020 21:09:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1EA020786 for ; Mon, 27 Jul 2020 21:09:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726278AbgG0VJO (ORCPT ); Mon, 27 Jul 2020 17:09:14 -0400 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]:46387 "EHLO outpost1.zedat.fu-berlin.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726140AbgG0VJO (ORCPT ); Mon, 27 Jul 2020 17:09:14 -0400 Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.93) with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (envelope-from ) id 1k0AMx-000fKE-7D; Mon, 27 Jul 2020 23:09:11 +0200 Received: from p57bd9e19.dip0.t-ipconnect.de ([87.189.158.25] helo=[192.168.178.139]) by inpost2.zedat.fu-berlin.de (Exim 4.93) with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (envelope-from ) id 1k0AMw-0046z4-Vd; Mon, 27 Jul 2020 23:09:11 +0200 Subject: Re: [PATCH] m68k/kernel - wire up syscall_trace_enter/leave for m68k To: Michael Schmitz , geert@linux-m68k.org Cc: linux-m68k@vger.kernel.org, schwab@linux-m68k.org, Greg Ungerer References: <1595823555-11103-1-git-send-email-schmitzmic@gmail.com> <13c91e87-7e26-1bc6-8ac0-68a790ee99cd@physik.fu-berlin.de> <5d98d276-c867-7f9b-f5b5-048e5e70ee3c@gmail.com> From: John Paul Adrian Glaubitz Autocrypt: addr=glaubitz@physik.fu-berlin.de; keydata= mQINBE3JE9wBEADMrYGNfz3oz6XLw9XcWvuIxIlPWoTyw9BxTicfGAv0d87wngs9U+d52t/R EggPePf34gb7/k8FBY1IgyxnZEB5NxUb1WtW0M3GUxpPx6gBZqOm7SK1ZW3oSORw+T7Aezl3 Zq4Nr4Nptqx7fnLpXfRDs5iYO/GX8WuL8fkGS/gIXtxKewd0LkTlb6jq9KKq8qn8/BN5YEKq JlM7jsENyA5PIe2npN3MjEg6p+qFrmrzJRuFjjdf5vvGfzskrXCAKGlNjMMA4TgZvugOFmBI /iSyV0IOaj0uKhes0ZNX+lQFrOB4j6I5fTBy7L/T3W/pCWo3wVkknNYa8TDYT73oIZ7Aimv+ k7OzRfnxsSOAZT8Re1Yt8mvzr6FHVFjr/VdyTtO5JgQZ6LEmvo4Ro+2ByBmCHORCQ0NJhD1U 3avjGfvfslG999W0WEZLTeaGkBAN1yG/1bgGAytQQkD9NsVXqBy7S3LVv9bB844ysW5Aj1nv tgIz14E2WL8rbpfjJMXi7B5ha6Lxf3rFOgxpr6ZoEn+bGG4hmrO+/ReA4SerfMqwSTnjZsZv xMJsx2B9c8DaZE8GsA4I6lsihbJmXhw8i7Cta8Dx418wtEbXhL6m/UEk60O7QD1VBgGqDMnJ DFSlvKa9D+tZde/kHSNmQmLLzxtDbNgBgmR0jUlmxirijnm8bwARAQABtFRKb2huIFBhdWwg QWRyaWFuIEdsYXViaXR6IChGcmVpZSBVbml2ZXJzaXRhZXQgQmVybGluKSA8Z2xhdWJpdHpA cGh5c2lrLmZ1LWJlcmxpbi5kZT6JAlEEEwEIADsCGw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Bi1nRqcqANtzC+WQFwekDzk2lGqNRDg56s+q0KtY scOkTAZQGVpD/8AaLH4v1w== Message-ID: Date: Mon, 27 Jul 2020 23:09:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <5d98d276-c867-7f9b-f5b5-048e5e70ee3c@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Original-Sender: glaubitz@physik.fu-berlin.de X-Originating-IP: 87.189.158.25 Sender: linux-m68k-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-m68k@vger.kernel.org On 7/27/20 10:48 PM, Michael Schmitz wrote: > On 27/07/20 10:03 PM, John Paul Adrian Glaubitz wrote: >> Hi Michael! >> >> On 7/27/20 6:19 AM, Michael Schmitz wrote: >>> m68k (other than Coldfire) uses syscall_trace for both trace entry >>> and trace exit. Seccomp support requires separate entry points for >>> trace entry and exit which are already provided for Coldfire. >>> >>> Replace syscall_trace by syscall_trace_enter and syscall_trace_leave >>> in preparation for seccomp support. Check return code of >>> syscall_trace_enter(), and skip syscall if nonzero. Return code >>> will be left at what had been set by by ptrace or seccomp. >> Correct me if I'm wrong, but shouldn't the skip happen when the return >> code is -1? At least that's what we're doing on SuperH and that seems >> to be what other architectures are doing as well. > > What other non-zero return codes do you expect syscall_trace_enter() to set, and what should the action in entry.S be? I just don't think we should do it any different than the other architectures which explicitly compare the return value against -1, i.e. RISC-V and PA-RISC. > (Note that according to my reading, your SH patch does not actually do what your description says. If syscall_trace_enter() returns a positive non-zero value, that value is _not_ used as changed syscall number. SH uses r3 for the syscall number, not r0). You are right, of course. I somehow mixed that up. You're right, it checks the return value of syscall_trace_enter and it should skip the syscall if syscall_trace_enter returns -1. > As far as I can see, any non-zero return code should abort the syscall, so I just test for that (for simplicity). Our use of the tracehook_report_syscall_entry() return code (directly passed back from syscall_trace_enter()) doesn't leave much choice there, see comment in include/linux/tracehook.h. My point is to stay consistent with the other architectures. > If later on seccomp needs any specific action, it should be easy enough to change the syscall number (offset PT_OFF_ORIG_D0 on the stack) or syscall return code (offset PT_OFF_D0). There's code in kernel/ptrace.c to do that AFAICS. > > Changing the behaviour of syscall_trace_enter() to match what other architectures do (return changed syscall number, not error code) is beyond the scope of this patch. I suspect the capability to change syscall numbers from ptrace code does predate the seccomp filter approach, and as m68k has never used it in the past, I don't see a point to add this now. Yes, I agree and my previous comment in this regard was wrong. >> Also, shouldn't that part of the change not be part of the patch that >> adds support for SECCOMP filter like in [1]? I don't think it makes >> sense to add the return code check unless the rest of SECCOMP filter >> has been implemented. > > After replacing syscall_trace() by syscall_trace_enter() and syscall_trace_leave(), there is a return code provided by syscall_trace_enter() which we must check, hence I added the check at the same time as replacing syscall_trace() for non-Coldfire m68k. > > (I note that the same check should probably be added to coldfire/entry.S.) Do we actually need to check the return value unless we implement SECCOMP_FILTER? (Which no doubt we will do ;-)). > I can't test any of the later seccomp related stuff, so I'd rather leave that bit to someone else who can. I will work on the necessary changes for libseccomp this week, so that we can test whether the libseccomp live tests pass correctly on a patched kernel. Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaubitz@debian.org `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913