Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1684671ybm; Sat, 30 May 2020 17:28:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxo6y+qMNbqttXZLSb62VZV95zDFOiWiv7gukFN3ixONvRJ/W1+rQO2M/Ge0T2hRDLsWveo X-Received: by 2002:a05:6402:52:: with SMTP id f18mr15255957edu.7.1590884922588; Sat, 30 May 2020 17:28:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590884922; cv=none; d=google.com; s=arc-20160816; b=h4Jg3i9n70IJeEvl5OxBwzB2p22REMsRn7vBb2XHMNcGIbbPQaVHJ4Qx17MBy2H1Yq 75TUGzQlQ6TRHzRiQblOf9e6HC2dZFSUtbs0LLG7qqVuCBmqkHkJvPvttZcXCXTNqsZI /Uxom58aDloWdjQqH1pQ3Hvpg0wjnIyL/6GM1Lqzj+5xK4ulFRgCjWaL0K/3Ijpd3yvk QjN43fv22kpAVOO7hXiWKs/qrxQHVtIdgVn3+3UR03elJ5CS6Ieoxa9h45ozbxq00Pm0 +NaDEYn5Pcy/+iSVq+fx2DMxMnWKgzw0lhw1ck9GRTeD27xLnJJ6IQNwnVhbQV7OeXOd 9Vng== 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 :user-agent:message-id:in-reply-to:date:references:organization :subject:cc:to:from; bh=RuDvFGqffZ8ezian2c9eG24T2l+MMuC2as71+FZs+So=; b=qiwUoBSKXw2hKWX+1l0NFfCVluTfRP7YlF3nbpSnZJRokDvNornIWnU8LuA8V5WEEE xBL0Jx3PopSdaWIDqTK44NenwTlj/1N2kXy8x8q9Ofh6uVI4AGN71xxbEtjWmxhKlUuS JsAK0O+UP/GnlIJxVxCXTItC2WRSTD4HgPHYTU35PQKfFmzbMp/TLlQ4TTo2X6DrBGaE rDldn9U28qwIFIgaTtzmUG7zqClX9t+8N2AQ3axJZl9XtwZqrp/m1DO7xXviRDP5QUCD xWmLnDsnwDP1U080F9sg7kctRrnAiV+QT/weSPRbOJi3Xdnf+D/L7Y5x7M4dXw7qP9DR Cleg== 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 gg13si2291767ejb.266.2020.05.30.17.28.17; Sat, 30 May 2020 17:28:42 -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 S1729534AbgEaA0Y convert rfc822-to-8bit (ORCPT + 99 others); Sat, 30 May 2020 20:26:24 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:53074 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729361AbgEaA0X (ORCPT ); Sat, 30 May 2020 20:26:23 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id CA2402A0357 From: Gabriel Krisman Bertazi To: Andy Lutomirski Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel@collabora.com, Thomas Gleixner , Kees Cook , Will Drewry , "H . Peter Anvin" , Paul Gofman Subject: Re: [PATCH RFC] seccomp: Implement syscall isolation based on memory areas Organization: Collabora References: <20200530055953.817666-1-krisman@collabora.com> Date: Sat, 30 May 2020 20:26:17 -0400 In-Reply-To: (Andy Lutomirski's message of "Sat, 30 May 2020 15:09:47 -0700") Message-ID: <85367hkl06.fsf@collabora.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Andy Lutomirski writes: >> On May 29, 2020, at 11:00 PM, Gabriel Krisman Bertazi wrote: >> >> Modern Windows applications are executing system call instructions >> directly from the application's code without going through the WinAPI. >> This breaks Wine emulation, because it doesn't have a chance to >> intercept and emulate these syscalls before they are submitted to Linux. >> >> In addition, we cannot simply trap every system call of the application >> to userspace using PTRACE_SYSEMU, because performance would suffer, >> since our main use case is to run Windows games over Linux. Therefore, >> we need some in-kernel filtering to decide whether the syscall was >> issued by the wine code or by the windows application. > > Do you really need in-kernel filtering? What if you could have > efficient userspace filtering instead? That is, set something up so > that all syscalls, except those from a special address, are translated > to CALL thunk where the thunk is configured per task. Then the thunk > can do whatever emulation is needed. Hi, I suggested something similar to my customer, by using libsyscall-intercept. The idea would be overwritting the syscall instruction with a call to the entry point. I'm not a specialist on the specifics of Windows games, (cc'ed Paul Gofman, who can provide more details on that side), but as far as I understand, the reason why that is not feasible is that the anti-cheat protection in games will abort execution if the binary region was modified either on-disk or in-memory. Is there some mechanism to do that without modiyfing the application? > Getting the details and especially the interaction with any seccomp > filters that may be installed right could be tricky, but the performance > should be decent, at least on non-PTI systems. > > (If we go this route, I suspect that the correct interaction with > seccomp is that this type of redirection takes precedence over seccomp > and seccomp filters are not invoked for redirected syscalls. After all, > a redirected syscall is, functionally, not a syscall at all.) > -- Gabriel Krisman Bertazi