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.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 DF358C433E1 for ; Sun, 31 May 2020 17:32:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A41EC206E2 for ; Sun, 31 May 2020 17:32:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="a3QBm8SS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A41EC206E2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2D6FF80007; Sun, 31 May 2020 13:32:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 287D78E0003; Sun, 31 May 2020 13:32:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19D2880007; Sun, 31 May 2020 13:32:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id F2E7E8E0003 for ; Sun, 31 May 2020 13:32:01 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A32AE180AD80F for ; Sun, 31 May 2020 17:32:01 +0000 (UTC) X-FDA: 76877707242.30.rest59_2ec216a6f1922 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id 8BEE6180B3C83 for ; Sun, 31 May 2020 17:32:01 +0000 (UTC) X-HE-Tag: rest59_2ec216a6f1922 X-Filterd-Recvd-Size: 4387 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Sun, 31 May 2020 17:32:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=j209R3MIJNW0AmdXt4PuONxQE6mEpvM3Y45tjx0sIg8=; b=a3QBm8SS+gWyaXsiQwSf8fYdOG NucDt/msSaafhoTuXevyNBKu7wKLWpsYmIpBL8HluJTO9AYr7ezSYDFHgRx8w5flsTMlFv5XX2nsx 1Hgr6+fd76mPBd1EOohPTEFANvw7HjFqMr9NpYZZCVKDSqc7VdJUV2jdp9t6S7Jw4HTn7UtDn14uh pzfXNvUck9G1+JZOw6c/NKoh8afnwG7SC01YDW7QrXwpNNMj9af3ByqUxVxi2dMlmGjV/xfkIDZq/ mAc1Q1sghAipYSYngcp8n0XZJMuErJD13dJ5PuELRN/gvykQTWUpItzcQRgyAGgHEP/RHt4suuLkT ZSACtiHA==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jfRoT-0007Ll-FD; Sun, 31 May 2020 17:31:57 +0000 Date: Sun, 31 May 2020 10:31:57 -0700 From: Matthew Wilcox To: Paul Gofman Cc: Gabriel Krisman Bertazi , Kees Cook , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel@collabora.com, Thomas Gleixner , Andy Lutomirski , Will Drewry , "H . Peter Anvin" , linux-security-module@vger.kernel.org, Zebediah Figura Subject: Re: [PATCH RFC] seccomp: Implement syscall isolation based on memory areas Message-ID: <20200531173157.GG19604@bombadil.infradead.org> References: <20200530055953.817666-1-krisman@collabora.com> <202005300923.B245392C@keescook> <851rn0ejg9.fsf@collabora.com> <9a512096-7707-3fc6-34ba-22f969c0f964@gmail.com> <20200531164938.GF19604@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 8BEE6180B3C83 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 Sun, May 31, 2020 at 08:10:18PM +0300, Paul Gofman wrote: > On 5/31/20 19:49, Matthew Wilcox wrote: > > On Sun, May 31, 2020 at 03:39:33PM +0300, Paul Gofman wrote: > >>> Paul (cc'ed) is the wine expert, but my understanding is that memory > >>> allocation and initial program load of the emulated binary will go > >>> through wine. It does the allocation and mark the vma accordingly > >>> before returning the allocated range to the windows application. > >> Yes, exactly. Pretty much any memory allocation which Wine does needs > >> syscalls (if those are ever encountered later during executing code from > >> those areas) to be trapped by Wine and passed to Wine's implementation > >> of the corresponding Windows API function. Linux native libraries > >> loading and memory allocations performed by them go outside of Wine control. > > I don't like Gabriel's approach very much. Could we do something like > > issue a syscall before executing a Windows region and then issue another > > syscall when exiting? If so, we could switch the syscall entry point (ie > > change MSR_LSTAR). I'm thinking something like a personality() syscall. > > But maybe that would be too high an overhead. > > IIRC Gabriel had such idea that we discussed. We can potentially track > the boundary between the Windows and native code exectution. But issuing > syscall every time we cross that boundary may have a prohibitive > performance impact, that happens way too often. What we could do is to > put the flag somewhere, but that flag has to be per thread. E. g., we > could use Linux gs: based thread local storage, or fs: based address > (that's what Windows using for thread local data and thus Wine maintains > also). If Seccomp filters could access such a memory location (fetch a > byte from there and put into the structure accessible by BPF_LD) we > could use SECCOMP_MODE_FILTER, I think. If it's the cost of the syscall that's the problem, there are ways around that. We'd still want a personality() call to indicate that the syscall handler should look (somewhere) to determine the current personality, but that could be issued at the start of execution rather than when we switch between Windows & Linux code.