From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A9CFC433DF for ; Sun, 31 May 2020 00:59:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1E1F32074B for ; Sun, 31 May 2020 00:59:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=amacapital-net.20150623.gappssmtp.com header.i=@amacapital-net.20150623.gappssmtp.com header.b="Gdj6kN2m" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E1F32074B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amacapital.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8B73980007; Sat, 30 May 2020 20:59:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 867818E0003; Sat, 30 May 2020 20:59:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7566180007; Sat, 30 May 2020 20:59:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id 59B2A8E0003 for ; Sat, 30 May 2020 20:59:55 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 1297C4404 for ; Sun, 31 May 2020 00:59:55 +0000 (UTC) X-FDA: 76875207150.17.mine02_73a08e58c2142 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id EA551180D0180 for ; Sun, 31 May 2020 00:59:54 +0000 (UTC) X-HE-Tag: mine02_73a08e58c2142 X-Filterd-Recvd-Size: 5887 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Sun, 31 May 2020 00:59:54 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id d3so2806452pln.1 for ; Sat, 30 May 2020 17:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=DjhjFd8XT3PVpUMAo4NBwDCmtRQKw/8uWc7BwYUQh2w=; b=Gdj6kN2m675KZ3jPAOrs0bW8hUmJz6i+11KLnT7ImZ6PcykEIyBkmt7O8gqwqHmiK+ S0AV7eIvYyZ3BeiCaddKTT1pBt0iQ/h6nH0UTYTwUeXFeUNOgCezQ7JsLAAaHRtefhO3 kW2Ss4ZjAJ79PNeWnlZq3+C+MmmYS/gzqtogZ6XVIJJwUdvOa/OTp4ULtvnujJorL2mX 2mcIAto2oojAKslnz9Vg+HKuCBCyXz02wUq9TBy+b3FoOffG8qUrWjoH/EvTekdQYai8 6Mo3U0YXuted9+I0j1O2NbFzIUajKyGuJjmQE3hPNc0iYdSm41Hhscc3Q0bZFtArT5s+ uM5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=DjhjFd8XT3PVpUMAo4NBwDCmtRQKw/8uWc7BwYUQh2w=; b=Dnuzp9BDhil/oaHyd/6LBekK7ZSzkMU9BPC31ZYFQCkZ8VMErt8kaU1WQP/aEc2ZCH 6carq6Q30AZDqJPShcyEJtkSwBj98z7QgN0Sfb+fqgvA9/cLo14CBMtvq9v70V0PRcQt 2fPGz5wm2p2kMSXQceI4IBPHSMoc0ejKlCKzMaoHnFvdS2/7gewAgi2ucbm2qDOBtIxV 6LRsnX2tc5ZOVzwHLQj/4Y6baJZak/orL+DOqL/dgPvU6uCdCbFVrf2Aa63jz+eYk9cT T/UDk14EiDtMO9qQs6ufJRAn+PK7SeaiQ3WVIOOdZhjYhx+i3iDG5laz8cuetv4pLCEP 4A6g== X-Gm-Message-State: AOAM533L1+jqGhuaaa9tUYP/nXyTBgcL/7BzhJkWz/SpXBx9J1Q9V2dA P6k3HstJ9wQKY2/qeaAvV/3KRw== X-Google-Smtp-Source: ABdhPJzdbnnmwL07quMsROiAovs/kh8goZJj6XAqksxPOVg5stBzrE3yNPfQxvp6cVn8/CpbErgvog== X-Received: by 2002:a17:902:b097:: with SMTP id p23mr3309892plr.14.1590886793144; Sat, 30 May 2020 17:59:53 -0700 (PDT) Received: from ?IPv6:2600:1010:b04c:ab45:e4c2:341d:a35e:6a40? ([2600:1010:b04c:ab45:e4c2:341d:a35e:6a40]) by smtp.gmail.com with ESMTPSA id x25sm9660840pge.23.2020.05.30.17.59.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 30 May 2020 17:59:52 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: [PATCH RFC] seccomp: Implement syscall isolation based on memory areas Date: Sat, 30 May 2020 17:59:47 -0700 Message-Id: <079539BF-F301-47BA-AEAD-AED23275FEA1@amacapital.net> References: <85367hkl06.fsf@collabora.com> Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel@collabora.com, Thomas Gleixner , Kees Cook , Will Drewry , "H . Peter Anvin" , Paul Gofman In-Reply-To: <85367hkl06.fsf@collabora.com> To: Gabriel Krisman Bertazi X-Mailer: iPhone Mail (17E262) X-Rspamd-Queue-Id: EA551180D0180 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: > On May 30, 2020, at 5:26 PM, Gabriel Krisman Bertazi wrote: >=20 > =EF=BB=BFAndy Lutomirski writes: >=20 >>>> On May 29, 2020, at 11:00 PM, Gabriel Krisman Bertazi wrote: >>>=20 >>> =EF=BB=BFModern Windows applications are executing system call instructi= ons >>> 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.= >>>=20 >>> 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. >>=20 >> 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. >=20 > Hi, >=20 > 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. >=20 > Is there some mechanism to do that without modiyfing the application? I=E2=80=99m suggesting that the kernel learn how to help you, maybe like thi= s: prctl(PR_SET_SYSCALL_THUNK, target, address_of_unredirected_syscall, 0, 0, 0= , 0); This would be inherited on clone/fork and cleared on execve. >=20 >> 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. >>=20 >> (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.) >>=20 >=20 >=20 > --=20 > Gabriel Krisman Bertazi