Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4711030pxa; Mon, 10 Aug 2020 16:30:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQLlUvAK60JIvi+gL5XzoIp2E0XGx2o9g43azZEfQUFUKmKIaM5nTe9/34Geyy0cwQXE/n X-Received: by 2002:a17:906:4dc8:: with SMTP id f8mr24251117ejw.257.1597102231100; Mon, 10 Aug 2020 16:30:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597102231; cv=none; d=google.com; s=arc-20160816; b=AKZ2xy/hUAnrn0SWIY9tLI0k5XRzjEn7BO971KYvCCQJB3LrR0NATDIlCZ1qJaq3+b KZJqs/T+zXsNXSHKaySw/4cl3Z/xr6Ek51p+qNjhZBWt10ehBOo0Mfu4Gk6++hnMQ1Sa wRN5z66d83VtmQ4u2nW9izofy6KuLVJDa6pIZ2Aih5XHbs6tIPKQP7XEJMijgCtwKsyx yTWIKYorwkghr7Ve3z/Uv89kBwhYXw/+YT3E7aClvHFeRKyji5c9jXYUyXVlFkf5gZBu hElpGafYaWSW1dnQ7S+svj9F/Xc6nShtn0oJhxROVZQETsZdrjBKBsm5WNMdno9GZInM u+6g== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=UukyfGOciAzKG287gQRuaYF7NHr4QKaXvFT0dCgSFu0=; b=nUoS0kTTNOh3LA6hoaTfMDPzhS3rlsrs5vFSHPM26Q4CFwhxf4kymHzP5LnjNg4+ah blM3wCSXuQLyMBLZYSZlHxpY6Ok9p1q8WNjYrEauSvsGmHsxxv1d65+d6ghS2PleJ4v5 58VrgNahC6GVNUc6Kf797N7q5xiG9SnmRAvwopd42Etuw2gzFz3/KVXXl5lXp5YdqaPp q80vFHiCiGb//wBsCiomCwLjEPuxmWig0oHVhNUjUaqpvF1ZfvaIlaGjIjUFl+61Rr7D 37TnZMZ5YNHitKYyorD9G38VWDmtWETf6noJPKj9qvf4cH6pYGhZG+bx/jwgtDVugm+R TDYg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s21si11117808eja.382.2020.08.10.16.30.05; Mon, 10 Aug 2020 16:30:31 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727978AbgHJX1M (ORCPT + 99 others); Mon, 10 Aug 2020 19:27:12 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:51412 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726634AbgHJX1H (ORCPT ); Mon, 10 Aug 2020 19:27:07 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id B004628DB7F From: Gabriel Krisman Bertazi To: luto@kernel.org, tglx@linutronix.de Cc: keescook@chromium.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, willy@infradead.org, linux-kselftest@vger.kernel.org, shuah@kernel.org, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH v5 6/9] kernel: entry: Support Syscall User Dispatch for common syscall entry Date: Mon, 10 Aug 2020 19:26:33 -0400 Message-Id: <20200810232636.1415588-7-krisman@collabora.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200810232636.1415588-1-krisman@collabora.com> References: <20200810232636.1415588-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Syscall User Dispatch (SUD) must take precedence over seccomp, since the use case is emulation (it can be invoked with a different ABI) such that seccomp filtering by syscall number doesn't make sense in the first place. In addition, either the syscall is dispatched back to userspace, in which case there is no resource for seccomp to protect, or the syscall will be executed, and seccomp will execute next. Regarding ptrace, I experimented with before and after, and while the same ABI argument applies, I felt it was easier to debug if I let ptrace happen for syscalls that are dispatched back to userspace. In addition, doing it after ptrace makes the code in syscall_exit_work slightly simpler, since it doesn't require special handling for this feature. Signed-off-by: Gabriel Krisman Bertazi --- kernel/entry/common.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/entry/common.c b/kernel/entry/common.c index 80db3f146462..f05a4ee094a1 100644 --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -6,6 +6,8 @@ #include #include +#include "common.h" + #define CREATE_TRACE_POINTS #include @@ -47,6 +49,12 @@ static inline long do_syscall_intercept(struct pt_regs *regs) int sysint_work = READ_ONCE(current->syscall_intercept); int ret; + if (sysint_work & SYSINT_USER_DISPATCH) { + ret = do_syscall_user_dispatch(regs); + if (ret == -1L) + return ret; + } + if (sysint_work & SYSINT_SECCOMP) { ret = __secure_computing(NULL); if (ret == -1L) -- 2.28.0