Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp2179535ybm; Sun, 31 May 2020 11:14:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxl8WXcemmhbz+a+hnBxs9Dfofyk5ZlP5obVWj9/X3bdhgQS10/N61ddvvHjxdc5fC75uX X-Received: by 2002:a50:cb8a:: with SMTP id k10mr18348015edi.345.1590948886078; Sun, 31 May 2020 11:14:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590948886; cv=none; d=google.com; s=arc-20160816; b=YEIcCZnJPdNIqdOBqzFSCvlfmgGaiZ6nOQfyZHSbGpVIusiyDkKCiedTwR85SG8DMY s1Eal5Oh6e8Lnxce+B8KQ/GK/YyDh8bgfHVAl5eFRLEoAsFTo8FKz6bpN98NrEyfFxwQ o7K9OXaDkWLHhITNdFPCJY7bSiFsjwicg7ZqPojq/HIb0XoHVAwCQVhR+4T7dze4ZmTe XnZaqPUtqTNgTe3Ko3c3TOI+smMe2WR/TQeKNj2euf2arJzFzj1zddoWcSJJJREPVPDs jJIENRCv4qa54O7ItMK5NbtjcJT2ocxM5ftZxCgFYComK8plfA8bk6VxLPiA9qb7Ph59 zSCA== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=8IKX/OR/pV3fckOZCUMzV/2OnUtnawhLhqDG+nWHINo=; b=0JmeKUDcQIxK+eAP/plqhLEseF/oqDrErfM3MZRt98KK1MqZRKiLVnDgf1zgN+GfMQ XPTzx2bz8UuhWssIBtD+NcLAHYXE4HPlDRMfHOqU5Rqmtee0Vvn9xY3F+5v2BE768MIZ 2+vTSPrJf9BHzwTJnxi7A/MdMqq3x4LN2DxTP4Fh7JOZjdJpuMeTwW+q6NI9Ym1r6MSj /LK3wL9JciJy9RMOxf/X8WBBIdADJmfccjxOPOZWPV+Kd676ADThj7IzIV/SnsWU31FK 9sVuJHZA3EdN1dvaWD8yZi8Fjn7QAAYI+U8EPVLleZpjS28hV3WyDT9YtKb/DBFvFxsY WPpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TOGypFka; 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 n7si870596edt.65.2020.05.31.11.14.21; Sun, 31 May 2020 11:14:46 -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=TOGypFka; 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 S1728241AbgEaSKW (ORCPT + 99 others); Sun, 31 May 2020 14:10:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:45974 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726081AbgEaSKV (ORCPT ); Sun, 31 May 2020 14:10:21 -0400 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 E1AC1206E2 for ; Sun, 31 May 2020 18:10:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590948621; bh=coKg1dFR2wviMowGB6sRKtlm96WsZo+FklYL+j+PeIU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=TOGypFkaW4/TfPCmS5SCQN1GbSYnBKnbrtk9tQSbQxFXTueNA6ujFwr6IgLLlSdHd nRVOcsoGEoI1eCI+Ekj2x6FKelUwoTvohXc3NHx4FWn7gKGoNoy9COLNEbHWTzjgxF +EIHYGwov2gPdAta3vlWRq6LlNh06j/EAR5uZAqU= Received: by mail-wm1-f48.google.com with SMTP id d128so9211214wmc.1 for ; Sun, 31 May 2020 11:10:20 -0700 (PDT) X-Gm-Message-State: AOAM532eUy6R0ZLEvsh0Mo9TttQeLpIqn5Y0I5sp9IdbG7ORAtyDayg8 d1j5r+57pfYJaZf0u1ltSCXEeYTUI/qlENyxIn7g5A== X-Received: by 2002:a1c:46c3:: with SMTP id t186mr17292708wma.36.1590948619546; Sun, 31 May 2020 11:10:19 -0700 (PDT) MIME-Version: 1.0 References: <85367hkl06.fsf@collabora.com> <079539BF-F301-47BA-AEAD-AED23275FEA1@amacapital.net> <50a9e680-6be1-ff50-5c82-1bf54c7484a9@gmail.com> In-Reply-To: <50a9e680-6be1-ff50-5c82-1bf54c7484a9@gmail.com> From: Andy Lutomirski Date: Sun, 31 May 2020 11:10:08 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH RFC] seccomp: Implement syscall isolation based on memory areas To: Paul Gofman Cc: Gabriel Krisman Bertazi , Linux-MM , LKML , kernel@collabora.com, Thomas Gleixner , Kees Cook , Will Drewry , "H . Peter Anvin" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 31, 2020 at 5:56 AM Paul Gofman wrote: > > On 5/31/20 03:59, Andy Lutomirski wrote: > > > > I=E2=80=99m suggesting that the kernel learn how to help you, maybe lik= e this: > > > > 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. > > > If we are talking about explicit specification of syscall addresses to > be trapped by Wine, the problem here is that we don't have any way of > knowing the exact addresses of syscalls to be redirected. We would need > some way to find those syscalls in the highly obfuscated dynamically > generated code, the whole purpose of which is to prevent disassembling, > debugging and finding things like that in it. What we do know is that if > a syscall is executed from any memory which Wine allocates for Windows > application then it should be treated as Windows syscall and routed to > the Wine's dispatch function. Those code areas can be dynamically > allocated and deallocated. That's not what I meant. I meant that you would set the kernel up to redirect *all* syscalls from the thread with the sole exception of one syscall instruction in the thunk. This would catch Windows syscalls and Linux syscalls. The thunk would determine whether the original syscall was Linux or Windows and handle it accordingly. This may interact poorly with the DRM scheme. The redzone might need to be respected, or stack switching might be needed.