Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2364208ima; Thu, 25 Oct 2018 14:03:13 -0700 (PDT) X-Google-Smtp-Source: AJdET5dQKMSdz3MNpb1HL1pdbneI9G2I5VIm6CIUlX/uaAnKM6d2yjfOiKacbycxEe/HqrZVmx2R X-Received: by 2002:a17:902:778a:: with SMTP id o10-v6mr724725pll.5.1540501393738; Thu, 25 Oct 2018 14:03:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540501393; cv=none; d=google.com; s=arc-20160816; b=jV5U7R2r+qsZsusy5vuCzvo5nxJt/JvEhnDBF5UIm4fzV/sQXHT8hMN9ZEq8USeYtS lnLArDE+XgevOfjiLJGXVUSNbbj2Hn5E+3VS0JRe02+78fZdnY8cRWD/k/Fg3LYirOtE 27dxd9RMZ2Uio3EZZGVq0XT1OKgJIvhO4gdGaguReNSiB8YPl4o/YdNHhuxDb+2u7IgL LKkulXvRJuarw16BYRfimgY9JPxwMAPq0RPfkobC9MLEGldFBbOtDDOwQnHst21Aod7e B2qS+jsLARjzg4t0I134UwzAatt2z1Z8Mj8OH64Yov4jeihXl0sO9DBeepyYGd+Cyjxf L8LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=gDl9tuLjrc5aO/xWHsA1eJ2QMDOIODaJdJyMWgsmf5Y=; b=ykwQijrJ0AT3+2g10WpxiGXmw6hCE17jp6JzXUCi34jR0uxp6Xf9svKSGZs13vHJUV g+CCBpvv8LXURLqJDPvPfraonkc3dj/ovShVSYc0g1WCUnS8I56bJNIOx3NMkJbez+gc 1YCBcGtHCCZB1TW6rs/TvEsZvcZ0K6e7YG9cUuQquXGEj0Or5vbG0Dx6T9fiHFiYMhYE x7I8XN7TMP4y/IOS+1YJpBYqfdcBupDmv30UtozH5cCk1zOb9120VVSY8/Eqgz1NM5xX m6PipFCmudhZh7GSLDkglemRtKc+BjqBOMu3G5RL14LNgiNSPuzYqybYJs0mS+0YX7sw atEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b="ePHL/mmu"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d4-v6si8703837pgj.341.2018.10.25.14.02.55; Thu, 25 Oct 2018 14:03:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b="ePHL/mmu"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726149AbeJZFgv (ORCPT + 99 others); Fri, 26 Oct 2018 01:36:51 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:45548 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726013AbeJZFgu (ORCPT ); Fri, 26 Oct 2018 01:36:50 -0400 Received: by mail-wr1-f66.google.com with SMTP id n5-v6so6943820wrw.12 for ; Thu, 25 Oct 2018 14:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gDl9tuLjrc5aO/xWHsA1eJ2QMDOIODaJdJyMWgsmf5Y=; b=ePHL/mmuAgPXJgnbLsyesnGMr6AErgUyRrxtmuq70KtYnTzTq1w/5JW2md6UlqMxvW RWe/nTaDfx++fhqFJKRBH8cVwnZuf/Y6pgflh2o1zdSs5W+bColy0TAZdLe+cApl2ApP +lWSyc/o6TLAY4WQhtXNHNDFVI6pU3apg1GilJRxCU5b/Umh5flvA8b3+Exc8PNf03Xe ws/WPDXO8apJqmpKhXP7upNvKVKEgwNBxrJ8awTatqG7rAZaiZVvUxQNm7fNxV4itB2C oiNrVX092EjZ0/5GLqsgq1HA/sQQuBQ+4KXtEL5IReWMVMCvWp7qVqrie/sH0KwZhP+t NH+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gDl9tuLjrc5aO/xWHsA1eJ2QMDOIODaJdJyMWgsmf5Y=; b=LTWjSo+yuIgSKKgZ01f2x6EUbTMWiAq7g8AHxTKRpHhSq3r7PAKC4ooyzZPfyAL5at RlNaFD0/6aQkM7XhclnhklMqmD1j0pI4sDHkooJNl6nv3fNxzFmRfhEQvnevMY9FG0Pr WoW3zGLIyO3Ohfq2i/fNnp9cx5vfUx+o+wiEIBlKiC5rCazyVoN6tPMOYitg0SJqiM2B JjZIJM96KCpUaHpR/pOi+aJP2BmRZ9YC/9dDUwihEXHe9rxopjegWJ7MvOCiDNk3a7xW aibN7dt1lA0N3YNwDE4k0pG4DxKJZ3FRjqFkEDupnrTDreajUACH9fw3mK55NB5av8wD Q0ew== X-Gm-Message-State: AGRZ1gJi965r52PLkNY6u4z2hwnd1axOAao34npwCXAMYKN1QkjKVv2T LSkoUkLs2Js5LVLcvKHoJk7GDpjuejPr81I9zEhghQ== X-Received: by 2002:adf:97d3:: with SMTP id t19-v6mr3507907wrb.283.1540501351994; Thu, 25 Oct 2018 14:02:31 -0700 (PDT) MIME-Version: 1.0 References: <20181024204036.8799-1-palmer@sifive.com> <20181024204036.8799-3-palmer@sifive.com> In-Reply-To: From: Andy Lutomirski Date: Thu, 25 Oct 2018 14:02:20 -0700 Message-ID: Subject: Re: [PATCH 2/2] RISC-V: Add support for SECCOMP To: Kees Cook Cc: palmer@sifive.com, linux-riscv@lists.infradead.org, aou@eecs.berkeley.edu, Paul Moore , Eric Paris , Will Drewry , wesley@sifive.com, David Howells , Thomas Gleixner , pombredanne@nexb.com, Greg KH , kstewart@linuxfoundation.org, LKML , linux-audit@redhat.com, david.abdurachmanov@gmail.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 24, 2018 at 2:42 PM Kees Cook wrote: > > On Wed, Oct 24, 2018 at 1:40 PM, Palmer Dabbelt wrote: > > From: "Wesley W. Terpstra" > > > > This is a fairly straight-forward implementation of seccomp for RISC-V > > systems. > > > > Signed-off-by: Wesley W. Terpstra > > Signed-off-by: Palmer Dabbelt > > --- > > arch/riscv/Kconfig | 18 ++++++++++++++++++ > > arch/riscv/include/asm/seccomp.h | 10 ++++++++++ > > arch/riscv/include/asm/syscall.h | 6 ++++++ > > arch/riscv/include/asm/thread_info.h | 1 + > > include/uapi/linux/audit.h | 1 + > > 5 files changed, 36 insertions(+) > > create mode 100644 arch/riscv/include/asm/seccomp.h > > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > > index a344980287a5..28abe47602a1 100644 > > --- a/arch/riscv/Kconfig > > +++ b/arch/riscv/Kconfig > > @@ -28,6 +28,7 @@ config RISCV > > select GENERIC_STRNLEN_USER > > select GENERIC_SMP_IDLE_THREAD > > select GENERIC_ATOMIC64 if !64BIT || !RISCV_ISA_A > > + select HAVE_ARCH_SECCOMP_FILTER > > I think this patch is missing most of the actual seccomp glue? > > config HAVE_ARCH_SECCOMP_FILTER > bool > help > An arch should select this symbol if it provides all of these things: > - syscall_get_arch() > - syscall_get_arguments() > - syscall_rollback() > - syscall_set_return_value() > - SIGSYS siginfo_t support > - secure_computing is called from a ptrace_event()-safe context > - secure_computing return value is checked and a return value of -1 > results in the system call being skipped immediately. > - seccomp syscall wired up > > I only see syscall_get_arch(). Nothing is using TIF_SECCOMP (I'd > expect a masked check in entry.S -- it seems like tracepoints are > getting missed too? I see it handled in ptrace.c but not checked in > entry.S?) There's no checking for seccomp in ptrace.c, etc. Hi RISC-V people: I strongly, strongly suggest that you rewrite your asm to work the way that x86's does: have a function called prepare_exit_to_usermode() and make it work more or less like x86's. Doing all the exit work in asm like you are is just setting you up for a world of pain. --Andy