Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp889775ybh; Wed, 22 Jul 2020 16:21:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIjl1m/OWI1//NM4/9zGucStM/EFDHCJI4HcDuhH+2m7ZfGl3AVpS4qlxkU+ZifjrYMbmc X-Received: by 2002:a05:6402:2cb:: with SMTP id b11mr1780006edx.66.1595460071187; Wed, 22 Jul 2020 16:21:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595460071; cv=none; d=google.com; s=arc-20160816; b=qmg33xcmoPAsuFPYHE4ShBpvRLQ4raJMQhFuHQv9TSYJFIrHbk9EmIkOms6PGWsEF4 wuHWXxdKrPDdaIaL6LVj6yaTvuRVNfpfH89628hLzsz2LMWEQ4jhtYQX+lVJGSU2Ld0L f/qheNhZz5PsQ6NDg0ZCS0xO9iyTrUn0O5BuG+V+I7OEJp6r41F1ZtyKajJasDw+SDMy OXfjRMJzXIIRFRgtmrw6ep4B+Ep9iu0TggU6nTu2zmbAS0eXz2UnOlTHcJahNwc1viRn aX5sO0VuQEFaUzCiyMSYnMpY9LEldseVu3WUVZce4O81ANOf5eTYJuxJ8j1WVxDQHSN8 htJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject; bh=PaCvgsycg7P89HMeSWKTgtHZ+Cymgjvnh3Ijbm7zWo4=; b=RIIaHnxC9jkVIcFHizBPDEoY6n+Ofr9jXuBkjrFBdeDz9o1Q1bfTsemrM3lgPXi6xU KL9VuVb5i1WnFyQU3GpuiV1Jx3Rg7k4foHyyTscBICbt/nU5o+2nbGzZtZmOXUaTloEa TtO4clkENqHvBJZ8u/KvPvqrNHQl/bfuZCsIEpp0+E8mwFD3RXTSpdgHAhcfWNWr63FE fOu2XZkSq19lPiYFgIb1P0FD8YPTHw2skwKxMDbskBrF8ktmp+H5s2OYMbDElbM/vl3/ KrAbmqYq4OK/3z1zfBEOpJgH++VYKd5gAZ8YY4APiiD6oMIHRCh18skQNGwOOuF47Spv biaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i22si852350eja.516.2020.07.22.16.20.48; Wed, 22 Jul 2020 16:21:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733113AbgGVXU2 (ORCPT + 99 others); Wed, 22 Jul 2020 19:20:28 -0400 Received: from outpost1.zedat.fu-berlin.de ([130.133.4.66]:34279 "EHLO outpost1.zedat.fu-berlin.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726447AbgGVXU1 (ORCPT ); Wed, 22 Jul 2020 19:20:27 -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 1jyO2A-000cv0-LP; Thu, 23 Jul 2020 01:20:22 +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 1jyO2A-002Xd0-EP; Thu, 23 Jul 2020 01:20:22 +0200 Subject: Re: [PATCH 3/4] sh: Add SECCOMP_FILTER To: Michael Karcher , linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Yoshinori Sato , Rich Felker References: <20200722231322.419642-1-kernel@mkarcher.dialup.fu-berlin.de> <20200722231322.419642-3-kernel@mkarcher.dialup.fu-berlin.de> 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 cGh5c2lrLmZ1LWJlcmxpbi5kZT6JAlEEEwEIADsCGwMFCwkIBwMFFQoJCAsFFgI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2lGqNRDg56s+q0KtY scOkTAZQGVpD/8AaLH4v1w== Message-ID: <77da0625-b4b3-78ca-b540-208b7889bd75@physik.fu-berlin.de> Date: Thu, 23 Jul 2020 01:20:21 +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: <20200722231322.419642-3-kernel@mkarcher.dialup.fu-berlin.de> 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/23/20 1:13 AM, Michael Karcher wrote: > Port sh to use the new SECCOMP_FILTER code. > > Signed-off-by: Michael Karcher > --- > arch/sh/Kconfig | 1 + > arch/sh/kernel/entry-common.S | 2 ++ > arch/sh/kernel/ptrace_32.c | 5 +++-- > tools/testing/selftests/seccomp/seccomp_bpf.c | 8 +++++++- > 4 files changed, 13 insertions(+), 3 deletions(-) > > diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig > index 32d959849df9..10b510c16841 100644 > --- a/arch/sh/Kconfig > +++ b/arch/sh/Kconfig > @@ -27,6 +27,7 @@ config SUPERH > select GENERIC_SMP_IDLE_THREAD > select GUP_GET_PTE_LOW_HIGH if X2TLB > select HAVE_ARCH_AUDITSYSCALL > + select HAVE_ARCH_SECCOMP_FILTER > select HAVE_ARCH_KGDB > select HAVE_ARCH_TRACEHOOK > select HAVE_DEBUG_BUGVERBOSE > diff --git a/arch/sh/kernel/entry-common.S b/arch/sh/kernel/entry-common.S > index c4d88d61890d..ad963104d22d 100644 > --- a/arch/sh/kernel/entry-common.S > +++ b/arch/sh/kernel/entry-common.S > @@ -368,6 +368,8 @@ syscall_trace_entry: > mov.l 7f, r11 ! Call do_syscall_trace_enter which notifies > jsr @r11 ! superior (will chomp R[0-7]) > nop > + cmp/eq #-1, r0 > + bt syscall_exit > mov.l r0, @(OFF_R0,r15) ! Save return value > ! Reload R0-R4 from kernel stack, where the > ! parent may have modified them using > diff --git a/arch/sh/kernel/ptrace_32.c b/arch/sh/kernel/ptrace_32.c > index 64bfb714943e..25ccfbd02bfa 100644 > --- a/arch/sh/kernel/ptrace_32.c > +++ b/arch/sh/kernel/ptrace_32.c > @@ -485,8 +485,6 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs) > { > long ret = 0; > > - secure_computing_strict(regs->regs[0]); > - > if (test_thread_flag(TIF_SYSCALL_TRACE) && > tracehook_report_syscall_entry(regs)) > /* > @@ -496,6 +494,9 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs) > */ > ret = -1L; > > + if (secure_computing() == -1) > + return -1; > + > if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) > trace_sys_enter(regs, regs->regs[0]); > > diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c > index 252140a52553..6eb21685c88f 100644 > --- a/tools/testing/selftests/seccomp/seccomp_bpf.c > +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c > @@ -122,6 +122,8 @@ struct seccomp_data { > # define __NR_seccomp 358 > # elif defined(__s390__) > # define __NR_seccomp 348 > +# elif defined(__sh__) > +# define __NR_seccomp 372 > # else > # warning "seccomp syscall number unknown for this architecture" > # define __NR_seccomp 0xffff > @@ -1622,6 +1624,10 @@ TEST_F(TRACE_poke, getpid_runs_normally) > # define SYSCALL_SYSCALL_NUM regs[4] > # define SYSCALL_RET regs[2] > # define SYSCALL_NUM_RET_SHARE_REG > +#elif defined(__sh__) > +# define ARCH_REGS struct pt_regs > +# define SYSCALL_NUM gpr[3] > +# define SYSCALL_RET gpr[0] > #else > # error "Do not know how to find your architecture's registers and syscalls" > #endif > @@ -1693,7 +1699,7 @@ void change_syscall(struct __test_metadata *_metadata, > EXPECT_EQ(0, ret) {} > > #if defined(__x86_64__) || defined(__i386__) || defined(__powerpc__) || \ > - defined(__s390__) || defined(__hppa__) || defined(__riscv) > + defined(__s390__) || defined(__hppa__) || defined(__riscv) || defined(__sh__) > { > regs.SYSCALL_NUM = syscall; > } > Tested-by: John Paul Adrian Glaubitz -- .''`. 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