Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp1344427pxa; Fri, 28 Aug 2020 10:04:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbKw7b0Bpp22mHNBRZNpJYTMNMx4wO4rT2wp6IqW8wakZ+hYcQausPRItJuphVznDZaeUi X-Received: by 2002:a17:906:1757:: with SMTP id d23mr2795238eje.126.1598634242948; Fri, 28 Aug 2020 10:04:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598634242; cv=none; d=google.com; s=arc-20160816; b=UhdTYuKBr/K0z6SGICkmegnwbnYF8qu0FmnUFpAtdT/FWmfryiF285sVJQ4OM/8ig7 hlvsIV2UfDDgOdQwXVzdBxTxLQRQyD125Ipgrb40qoIA4GPN+0cmD9Q6eroxnDiNUeS7 5VVoipMGHrtWoBtuj8sKObzsPeiESA58UFrV0bDaxsPNmr/WM2adIX2mUdqlvNg9k9wC Qp5Ep6/VjHpZ3t5uGO/vPeROWQmQ4NzybS572NNOqJvLn02R3j5vBtjsKy8AWr+UOt37 tVAzzjTJjJs5eb2V6qtzpeMNYF6GFAEyYtsPq4A1jdeCsej5C5u23reV94LO0inVZUps Px7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ozBLqjy9ZnSPwi2ThOwDLrSuY+vxp2iTGVJ3RpH9lD0=; b=sNt8u+8LicudHJ0oql0PY4t9O55gWMp56w8viw+iVVKHthGg4rkOtabds78GIdQa1L /7R1RTgor/KDy/vj29YMDTgNqNrOTKnMceSlad8KSvUS2OnQcmnZaOdWBaF8b97mXQwv d4qnHnVzjBNsgMenfIqR5y3Oeu+YWU+1by7OHkn2sNrrCEIdO+lLP/D/XFlzAo0XNAA4 gUVQ28Mss4QqauWtWKfFEcad5mI1u0DEM32VpBNAN0h5213yLTuUJG4xrnyaoW5duSJQ /5QVOrDSUcAhLqzAkk/Bhv2LLUbZgBdnEX7je219dSnhsHOgO4BU5ywjZOfk4T5nOZFU 79OA== 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 a29si968686edj.418.2020.08.28.10.03.38; Fri, 28 Aug 2020 10:04:02 -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 S1726654AbgH1RDC (ORCPT + 99 others); Fri, 28 Aug 2020 13:03:02 -0400 Received: from brightrain.aerifal.cx ([216.12.86.13]:47714 "EHLO brightrain.aerifal.cx" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726436AbgH1RDB (ORCPT ); Fri, 28 Aug 2020 13:03:01 -0400 Date: Fri, 28 Aug 2020 13:03:00 -0400 From: Rich Felker To: John Paul Adrian Glaubitz Cc: Michael Karcher , linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, Yoshinori Sato Subject: Re: [PATCH 3/4] sh: Add SECCOMP_FILTER Message-ID: <20200828170259.GZ3265@brightrain.aerifal.cx> References: <20200722231322.419642-1-kernel@mkarcher.dialup.fu-berlin.de> <20200722231322.419642-3-kernel@mkarcher.dialup.fu-berlin.de> <20200828155024.GX3265@brightrain.aerifal.cx> <20200828163057.GY3265@brightrain.aerifal.cx> <82b625c2-23cb-69a4-7495-39427430c306@physik.fu-berlin.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <82b625c2-23cb-69a4-7495-39427430c306@physik.fu-berlin.de> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 28, 2020 at 06:38:09PM +0200, John Paul Adrian Glaubitz wrote: > Hi! > > On 8/28/20 6:30 PM, Rich Felker wrote: > > I'm about to test a patch along these lines and will report what I > > find. > > Let me know when you have something to test and I will test the patch as > well, making sure we're not breaking seccomp again. If you have a seccomp test setup, please try the following patch. I'm not sure if the end result is entirely correct, but I believe it's at least much closer to correct than the code was before or after adding SECCOMP_FILTER. diff --git a/arch/sh/kernel/entry-common.S b/arch/sh/kernel/entry-common.S index ad963104d22d..0560a8054215 100644 --- a/arch/sh/kernel/entry-common.S +++ b/arch/sh/kernel/entry-common.S @@ -368,9 +368,6 @@ 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 ! ptrace(POKEUSR). (Note that R0-R2 are @@ -382,7 +379,7 @@ syscall_trace_entry: mov.l @(OFF_R5,r15), r5 mov.l @(OFF_R6,r15), r6 mov.l @(OFF_R7,r15), r7 ! arg3 - mov.l @(OFF_R3,r15), r3 ! syscall_nr + mov r0, r3 ! syscall_nr, possibly changed to -1 ! mov.l 6f, r10 ! Number of syscalls cmp/hs r10, r3 diff --git a/arch/sh/kernel/ptrace_32.c b/arch/sh/kernel/ptrace_32.c index 25ccfbd02bfa..9e86cff041c7 100644 --- a/arch/sh/kernel/ptrace_32.c +++ b/arch/sh/kernel/ptrace_32.c @@ -503,7 +503,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs) audit_syscall_entry(regs->regs[3], regs->regs[4], regs->regs[5], regs->regs[6], regs->regs[7]); - return ret ?: regs->regs[0]; + return ret ?: regs->regs[3]; } asmlinkage void do_syscall_trace_leave(struct pt_regs *regs)