Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1597675ybh; Thu, 16 Jul 2020 17:23:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4DQNXgXDjrjFm41ty5NEPmYsDLWMDvbbEzfOUBFyaXpl5tRTONLPJQK3doiKxPoavIe81 X-Received: by 2002:aa7:d2c9:: with SMTP id k9mr6607763edr.98.1594945390084; Thu, 16 Jul 2020 17:23:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594945390; cv=none; d=google.com; s=arc-20160816; b=tyG99sERKuN1S4jLw9XfLisUE8VGujfNyGc76sZcW8AMM+IWRabZD1E+TbLfAv8XwB qS2vvglqfxTl5IXO3mZqRow65JXYSCBZOIhVV37YfvLvl8WvnIOpDVrRU7Y3h/POZ99B G/U/RN8QDr88p7/ueGtFcEdnn9XJmcVi46bnySrQAiXND1MIpRdZHXdcoWNOJz4wFLfz XGtOp0yV1B/K9Xh9MvxL2VF0m5sZVD5XfRzoUHh4JV1vbLdWNx2EzF3LJeWngDLsfr8g IXtdYLF1sH5JjpFCQX6aulndkhER+SQLyUjyl8Wh1wQSz0ROB7somCuS/aMFATilf/CV SHDA== 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=ApaWlLFETFGdr2tNchOlpB6HH2F8xy1CUHo9IexGeTQ=; b=HksSn0S+sVdRaPZX5dkpKlffqAFzX4eFSYvNI7Yy11b/BmE/f1b6mM0rOSOdYYb/nG Dw13SKqSKsTyTyXj2ZSxImsv03/9Jmf8AhB7XfRwj7xj+oSsF5Bsvw3qmQwiJvhDX44d Qr4W4r42GQZ314ez6Axe2Sj8gFjygXeju4ymFUT7YEJi1WZ2ZdI8iBEVtPPBTMB7t9o7 symk9te7+aylGEjFmiVgsRJk33cse9m9migPWJy0CTZ3jhul9VY+1JP6WxiZyGNSx73z t6oZHpph5u1zZecByZnh0fqPKaaFg4pJrFQV8Idqf7V8R9fVL7ChWx2Hzu14dFHo+A3o n4rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BXz3QKqi; 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 by2si4314364edb.103.2020.07.16.17.22.47; Thu, 16 Jul 2020 17:23:10 -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=BXz3QKqi; 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 S1726337AbgGQAUQ (ORCPT + 99 others); Thu, 16 Jul 2020 20:20:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:43720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726125AbgGQAUQ (ORCPT ); Thu, 16 Jul 2020 20:20:16 -0400 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 58A72207EA for ; Fri, 17 Jul 2020 00:20:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594945215; bh=dynZiMT160fFV318XcHN8vJ1LFq3IdJmZE81Qj67JHY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=BXz3QKqi5cKE5fh3RKhpo+RLAtmQYAk5eW485twQ4Cvsc8Kzi0ysV+OPGw4+KH5zJ ltvZJtC16tfj6Wse9+LLFHiaYZNJh550ZYV89+HfejCZ2PYSi+p0c9Aog9mOQOMq+Y JUc+qCzzvaADEOiiSFb5qJG3qaTvS0TS+wqCxoHs= Received: by mail-wr1-f47.google.com with SMTP id j4so9076049wrp.10 for ; Thu, 16 Jul 2020 17:20:15 -0700 (PDT) X-Gm-Message-State: AOAM5334qQnkICC419YZOe46CUQ0hNiyuCHy4LGl9h9HmqdrUaIC7kDw xL/gxZj1bOYzwFYesWcA/2GWMGLMXO086DpLFoyJ8g== X-Received: by 2002:adf:f707:: with SMTP id r7mr7398196wrp.70.1594945213901; Thu, 16 Jul 2020 17:20:13 -0700 (PDT) MIME-Version: 1.0 References: <20200716193141.4068476-1-krisman@collabora.com> <20200716193141.4068476-2-krisman@collabora.com> In-Reply-To: <20200716193141.4068476-2-krisman@collabora.com> From: Andy Lutomirski Date: Thu, 16 Jul 2020 17:20:02 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 1/2] kernel: Implement selective syscall userspace redirection To: Gabriel Krisman Bertazi Cc: Thomas Gleixner , LKML , kernel@collabora.com, Matthew Wilcox , Andrew Lutomirski , Paul Gofman , Kees Cook , "open list:KERNEL SELFTEST FRAMEWORK" , Shuah Khan 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 Thu, Jul 16, 2020 at 12:31 PM Gabriel Krisman Bertazi wrote: > This is quite nice. I have a few comments, though: You mentioned rt_sigreturn(). Should this automatically exempt the kernel-provided signal restorer on architectures (e.g. x86_32) that provide one? The amount of syscall entry wiring that arches need to do is IMO already a bit out of hand. Should we instead rename TIF_SECCOMP to TIF_SYSCALL_INTERCEPTION and have one generic callback that handles seccomp and this new thing? > +int do_syscall_user_dispatch(struct pt_regs *regs) > +{ > + struct syscall_user_dispatch *sd = ¤t->syscall_dispatch; > + unsigned long ip = instruction_pointer(regs); > + char state; > + > + if (likely(ip >= sd->dispatcher_start && ip <= sd->dispatcher_end)) > + return 0; > + > + if (likely(sd->selector)) { > + if (unlikely(__get_user(state, sd->selector))) > + do_exit(SIGSEGV); > + > + if (likely(state == 0)) > + return 0; > + > + if (state != 1) > + do_exit(SIGSEGV); This seems a bit extreme and hard to debug if it ever happens.