Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2474977imd; Fri, 2 Nov 2018 12:03:34 -0700 (PDT) X-Google-Smtp-Source: AJdET5epZGWyYdN62mS+haufrvBBqH6a28aMejUvKybTr9Rnv9Yq9K3VhY6XO1GBuVNCeaqBFtgR X-Received: by 2002:a17:902:aa0a:: with SMTP id be10-v6mr12907284plb.294.1541185414327; Fri, 02 Nov 2018 12:03:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541185414; cv=none; d=google.com; s=arc-20160816; b=ToOZw3irZijWEPQdgWhM8r/DXYxGuN2XsDQFX1oT8wT3KBAB4W7Rrz/hsKITLJF/6L SBGBKPWUzri+BKfrGblRSlkmEg/OtqUnVllX5SywmDdf8sgRv4mN70Mah8jFfUU6vukC 0BjKOo6gYHu2/Eb2cu/KQCeZNUYIHeq+sJZmjAzIDalAXUmFvPmy04siti4/viRMNqHq WjxXstq31V8FPjzQ7Ss5CbZslmrwZ1crd6nzwkkNM/HhfYqvjuy073Y+aDt7FekJ5foU kbL2yGdcjzl+SRdQIe6u72IzrtDIwRhBy6fnpwh5BJop3KyVKeg8o23iLHe5Qfjx0dk1 e9GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=BmgOn/yOoSR5HejHQH+1zKMqDw4ij/eJkqq+C7pQAUA=; b=V2DlEWcBWpKS8n4DDrFiGiPRKHqWko2xX36ltRJT3lCjq4ZnYbljGybyHhifyDP92m ykd1OtskoL/5g6yVdp4XnA0BiMXsnuiNY9QWGY/HNMms7InqXKJisSSUBtkM3UfVtqjo AS9V+CzRb3R+wcFJc3qUqQ85Ce6Itgl3EwrOGxgOOEhIf/GH8EohUV0NM5cafi+BtFs8 dhDUrGohvu8Xg1C5CRlZOmGmnmJcUIbbijMpGRPKFgcTS4j/mI+TU+GOTqj7pr+857YR Fy6gZPf6uXdTHdeS/C2L0u4wcywXIe+aMhSBc0yMHr6BGHwL3O7JzjK/F8kVOd1IO9fI oZWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=KX4kTb+d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e17-v6si33136581pgb.19.2018.11.02.12.03.19; Fri, 02 Nov 2018 12:03:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=KX4kTb+d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730251AbeKCELK (ORCPT + 99 others); Sat, 3 Nov 2018 00:11:10 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:33038 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730091AbeKCELI (ORCPT ); Sat, 3 Nov 2018 00:11:08 -0400 Received: by mail-ot1-f68.google.com with SMTP id q1so2629923otk.0 for ; Fri, 02 Nov 2018 12:02:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BmgOn/yOoSR5HejHQH+1zKMqDw4ij/eJkqq+C7pQAUA=; b=KX4kTb+d4WBipAeFvz9QabhXCg1pEOGQU9kYdFeIQmGul56l/GXBYRI9uMr2bmA/DI +n06ZyZ+nDd4NwyNbucA+J7jbo4/cfKglRvI+2BQzl12O44cAk4/IOrbdgMjndFPdZBa wCPLiVcZ4Bi79st4O64LtLOZQUT+vHAXmJU1u0GH7j5p+lWQQbP5H2InIHgFb5CCZl4K 0KHGVHqTwmBJauZyQaKARJEdFKSX7CEHxZngFjkx66v5CRNiAm+Z4CClKnpSC4+SxAwM w9aHBdLvONeJ4KdR+cyLmxnmI7zIjVXJyLOXKJZKr4iYzapJWbC0wGSYIoho099unyM1 Y9RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BmgOn/yOoSR5HejHQH+1zKMqDw4ij/eJkqq+C7pQAUA=; b=H94+ce3i50rk1aKWhYqmBGZ+NHJKxMkqSR0GUFT+CoPgyXsUVeIyy4sxaXZJroftU/ T1T0Ss1mDQ5AndqfsetYLgrZTD9Sl4NQCIVTHSi54hPudBLlA/s0JRsmElEkuA6WmpCT 35EigjkYeMyjgKweJZK2NfTQVxOdzWmnWICl8MsC7Qmf5pb4dBR8z6SOJFu9h2sanpQS ujXdhEbxmnpAUNUaVloVFCEPNJIJpEqYAkZ599z2cFNJiIkuEcQgXU353zVIxPtYE6z8 ajP0j76kcG4ZXExqiwOa5lUQIaH7ty4B7gEsoL9/c86bnwQ6HE4Bfqm7mII4tZB82HxQ GS3g== X-Gm-Message-State: AGRZ1gI+fmaJpz4w6RX0jCZSTFBR2rh7XKdYLUY6E1h4njkH52elCh/d 32gmnRJW7BDa0/GPefmdCKA2IsIkibDBHKMrEFVtcA== X-Received: by 2002:a9d:638f:: with SMTP id w15mr5149669otk.230.1541185369982; Fri, 02 Nov 2018 12:02:49 -0700 (PDT) MIME-Version: 1.0 References: <20181101193107.GE5150@brightrain.aerifal.cx> <20181102163034.GB7393@linux.intel.com> <7050972d-a874-dc08-3214-93e81181da60@intel.com> <20181102170627.GD7393@linux.intel.com> <20181102173350.GF7393@linux.intel.com> <20181102182712.GG7393@linux.intel.com> In-Reply-To: <20181102182712.GG7393@linux.intel.com> From: Jann Horn Date: Fri, 2 Nov 2018 20:02:23 +0100 Message-ID: Subject: Re: RFC: userspace exception fixups To: sean.j.christopherson@intel.com Cc: Andy Lutomirski , Dave Hansen , Linus Torvalds , dalias@libc.org, Dave Hansen , jethro@fortanix.com, jarkko.sakkinen@linux.intel.com, Florian Weimer , Linux API , "the arch/x86 maintainers" , linux-arch , kernel list , Peter Zijlstra , nhorman@redhat.com, npmccallum@redhat.com, serge.ayoun@intel.com, shay.katz-zamir@intel.com, linux-sgx@vger.kernel.org, andriy.shevchenko@linux.intel.com, Thomas Gleixner , Ingo Molnar , Borislav Petkov , carlos@redhat.com, adhemerval.zanella@linaro.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 2, 2018 at 7:27 PM Sean Christopherson wrote: > On Fri, Nov 02, 2018 at 10:48:38AM -0700, Andy Lutomirski wrote: > > This whole mechanism seems very complicated, and it's not clear > > exactly what behavior user code wants. > > No argument there. That's why I like the approach of dumping the > exception to userspace without trying to do anything intelligent in > the kernel. Userspace can then do whatever it wants AND we don't > have to worry about mucking with stacks. > > One of the hiccups with the VDSO approach is that the enclave may > want to use the untrusted stack, i.e. the stack that has the VDSO's > stack frame. For example, Intel's SDK uses the untrusted stack to > pass parameters for EEXIT, which means an AEX might occur with what > is effectively a bad stack from the VDSO's perspective. What exactly does "uses the untrusted stack to pass parameters for EEXIT" mean? I guess you're saying that the enclave is writing to RSP+[0...some_positive_offset], and the written data needs to be visible to the code outside the enclave afterwards? In other words, the vDSO helper would have to not touch the stack pointer (only using the 128-byte redzone to store spilled data, at least across the enclave entry), and return by decrementing the stack pointer by 8 immediately before returning (storing the return pointer in the redzone)? So you'd call the vDSO helper with a normal "call vdso_helper_address", then the vDSO helper does "add rsp, 8", then the vDSO helper does its magic, and then it returns with "sub rsp, 8" and "ret"? That way you don't touch anything on the high-address side of RSP while still avoiding running into CET problems. (I'm assuming that you can use CET in a process that is hosting SGX enclaves?)