Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp4316577ybt; Mon, 6 Jul 2020 01:18:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxluQgIEl8+f+neiMUasPpaLc8Kh7GFq1DtwtpXZ2pg+X3DRh+EI6KaI11marsd/gqRJ8FL X-Received: by 2002:a17:906:54a:: with SMTP id k10mr41000404eja.480.1594023533887; Mon, 06 Jul 2020 01:18:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594023533; cv=none; d=google.com; s=arc-20160816; b=dQPKiGKjkt8tcQjf4Ej8LfejphU5qFiijrJeRlS5ALQd6WM6hM1v3SEaaeX8Tg3tuu RHPqIvaCgn0YZSf255YCK+zu4abpC02edoqXlfXZotjsfecF81Udh+oSRDmACvTgApC+ krpYGCYyaqLoR9n8eS43lC+gejTyJnoJ/2TdYGWPKqdMpgyRy/vgdnRb6dOO8ntjb6RM xqzQy/fQJZ1u/1YFvKkHVGIwd6YOvuu89sFd4rGrufT1pWhP/uszycvHYHYXX4gIoG9W 64aOACS6JE34YhC5HRZFAimoIcIMUq2cJ4czsfYHGT0AIdtZ2joFkJPnnpyZp0tFC1k6 OCUQ== 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:dkim-signature; bh=uiJ+fbpKgUDT6Tx0HMU80LRom2JbyJKpqXFQvqamCr8=; b=uyaIgQgnH5HryI8t2Wlnbh0QhZDEracg5N1rgU8EhevGqIjvmvNj6llY0glYVWm/A9 wjGgetiM82vo1fR3xPMsVJF4JhXeRk1gfOuRgnWCBfGd5dxjvrie70aOAlSRToQZfVZy 7PauLb5XqmEuxNfbX/okpwIvPA3pGzs5sZw6jn5yHkwKCEZA5arWlOZHfsmPxN/9Mjq8 zhuEZIUd81U3nlL3p7bGG1D5QikUJ8pyQl4fqWLmiYhgS1ZA/0XJ6tiGTyJnAzPM8tvq hqKweKQzRy5FuhXaTuzuU/iHjyHZcedbHXD46JSARuaAyfkSxej0ZXxYd8OkUD6Ecq+P EosQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iWAHvxfF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f22si13435852edy.17.2020.07.06.01.18.31; Mon, 06 Jul 2020 01:18:53 -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; dkim=pass header.i=@kernel.org header.s=default header.b=iWAHvxfF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728301AbgGFIP5 (ORCPT + 99 others); Mon, 6 Jul 2020 04:15:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:38500 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726277AbgGFIP4 (ORCPT ); Mon, 6 Jul 2020 04:15:56 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CB7EC20739; Mon, 6 Jul 2020 08:15:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594023355; bh=6YmTM1KwwDkiZJp3aHQpt/yeMmff1B/qvXle8AM26Dg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iWAHvxfF8nbyMfjcdC2lpaaAjlF1hXSXt6DDyrRcFoG7auqNjMWo34j5rj6GU/Zoq mwt7c8TF0D6jU2ZdeicAVi4zrlk8MzdOzD84X5ERAFOZ0IBj6YkhzBrJ8G2iBLRRvO EXsv1eX2V3Yk3U/BbAp4tjkhZcVbur3yd2gy0qb4= Date: Mon, 6 Jul 2020 09:15:51 +0100 From: Will Deacon To: Kees Cook Cc: Keno Fischer , Linux Kernel Mailing List , Oleg Nesterov , Andy Lutomirski , Will Drewry Subject: Re: ptrace: seccomp: Return value when the call was already invalid Message-ID: <20200706081550.GA23032@willie-the-truck> References: <20200703083914.GA18516@willie-the-truck> <202007030815.744AAB35D@keescook> <20200703154426.GA19406@willie-the-truck> <202007030851.D11F1EFA@keescook> <20200704123355.GA21185@willie-the-truck> <202007042132.DAFA2C2@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202007042132.DAFA2C2@keescook> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 04, 2020 at 09:56:50PM -0700, Kees Cook wrote: > On Sat, Jul 04, 2020 at 01:33:56PM +0100, Will Deacon wrote: > > On Fri, Jul 03, 2020 at 08:52:05AM -0700, Kees Cook wrote: > > > On Fri, Jul 03, 2020 at 04:44:27PM +0100, Will Deacon wrote: > > > > On Fri, Jul 03, 2020 at 08:17:19AM -0700, Kees Cook wrote: > > > > > On Fri, Jul 03, 2020 at 09:39:14AM +0100, Will Deacon wrote: > > > > > > diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c > > > > > > index 5f5b868292f5..a13661f44818 100644 > > > > > > --- a/arch/arm64/kernel/syscall.c > > > > > > +++ b/arch/arm64/kernel/syscall.c > > > > > > @@ -121,12 +121,10 @@ static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, > > > > > > user_exit(); > > > > > > > > > > > > if (has_syscall_work(flags)) { > > > > > > - /* set default errno for user-issued syscall(-1) */ > > > > > > - if (scno == NO_SYSCALL) > > > > > > - regs->regs[0] = -ENOSYS; > > > > > > - scno = syscall_trace_enter(regs); > > > > > > - if (scno == NO_SYSCALL) > > > > > > + if (syscall_trace_enter(regs)) > > > > > > goto trace_exit; > > > > > > + > > > > > > + scno = regs->syscallno; > > > > > > } > > > > > > > > > > > > invoke_syscall(regs, scno, sc_nr, syscall_table); > > > > > > > > > > What effect do either of these patches have on the existing seccomp > > > > > selftests: tools/testing/selftests/seccomp/seccomp_bpf ? > > > > > > > > Tests! Thanks, I'll have a look. > > > > > > Thanks! > > > > > > (And either way, that this behavioral difference went unnoticed means we > > > need to add a test to the selftests for this patch.) > > > > Unsurprisingly, I don't think the tests go near this. I get 75/77 passes > > on arm64 defconfig with or without these changes. > > (What doesn't pass for you? I tried to go find kernelci.org test output, > but it doesn't appear to actually run selftests yet?) > > Anyway, good that the test output doesn't change, bad that seccomp has > missed a corner of this architecture interface. (i.e. the entire > TRACE_syscall fixture is dedicated to exercising the changing/skipping > interface, but I see now that it doesn't at all exercise any area of > ENOSYS results.) > > > We could add a test, but then we'd have to agree on what it's supposed to > > be doing ;) > > Well, if you look at change_syscall() in seccomp_bpf.c (once you stop > screaming) you'll likely share my desire to have more things that are > common across architectures. ;) So, to that end, yes, please, let's > define what we'd like to see, and then build out the (likely wildly > different per-architecture expectations). If I read this thread > correctly, we need to test: > > syscall(-1), direct, returns ENOSYS > syscall(-10), direct, returns ENOSYS > syscall(-1), SECCOMP_RET_TRACE+PTRACE_CONT, returns ENOSYS > syscall(-10), SECCOMP_RET_TRACE+PTRACE_CONT, returns ENOSYS > syscall(-1), ptrace+PTRACE_SYSCALL, returns ENOSYS > syscall(-10), ptrace+PTRACE_SYSCALL, returns ENOSYS > > do we need to double-check that registers before/after are otherwise > unchanged too? (I *think* just looking at syscall return should be > sufficient to catch the visible results.) There's also the case where the tracer sets the system call to -1 to skip it. Will