Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1355122pxa; Sun, 2 Aug 2020 04:57:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwEBmFx9iJlkonCN/C+KKG+Cr/g68Ido4Geuih0E4s0ifbz4Mc+14rBOmYt56wqte2PN4k X-Received: by 2002:a17:906:7790:: with SMTP id s16mr4618559ejm.254.1596369457314; Sun, 02 Aug 2020 04:57:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596369457; cv=none; d=google.com; s=arc-20160816; b=jhGVSbHi1jaLCptmrsWpcBwfkOFPJEv8K9JG6r7VV7z8IxE4gCFoMjjVGUv9Pu32Oz Z/MhKPiJ37b7JVt1y9RTY+QHbjszsFrTdOA0lc5qf9+K/tF0cDO93Rk2IWIcQEJ5EY0z bSvI4SXZ0i3xbzcSv5hxEdbj/sTsjXuqj60fPk0JUbFNcKnDSJRIBUkseCFJQO9E9ZDY tciRtZI9XV+7XoUo1GBUnmCbnp40/e9SIofNj733mfUl6uODSELVxCmURamoPfFi035g 43HRhf2A77VHI5bHkyr7y/k4ts/VzJjGiKi7u0t0NgE4IrpRkrLVljKOSYn0O9cbd3L4 Btag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=pKHLIaXY9urD93svBVyZYhHkrHo3JxH1PX547MJa9Lc=; b=YNZ3gabtjJOH+jjVYqv+agLtwkVvsbfPuXoV9kjuUfI3kVuYErGCQ5aMWt/Rhb4Yeg 0AdCJxF59AEiFwFHOe6kiNZ5yb3QWPXjxJKqk7rh+tEIo4zq5ONFlBrD7aVLFtz4/u1v Fn/Wik+oYOd8tjirJEBaDNV6X/eqVIrNi6gX44DXdOS7HSYYxCHUvXMgZ9Oktqjx0T9g V3UXmmA9X+O8BzRpepIbuiMWq72aGRlnWizAn9N5iu6S+j3EZXYXJ4VMl4usn2RXD4DA xwnk24mvbEH6d3ZvJDvYgwHbNtlw36RThpGi3zGnNamdEHgK2052etKawaiHrMpEhVm+ HSaA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f14si7600127edt.316.2020.08.02.04.57.15; Sun, 02 Aug 2020 04:57:37 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728217AbgHBL4L (ORCPT + 99 others); Sun, 2 Aug 2020 07:56:11 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:51162 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726578AbgHBL4K (ORCPT ); Sun, 2 Aug 2020 07:56:10 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id D07881C0BE1; Sun, 2 Aug 2020 13:56:08 +0200 (CEST) Date: Sun, 2 Aug 2020 13:56:01 +0200 From: Pavel Machek To: David Laight Cc: 'Andy Lutomirski' , "madvenka@linux.microsoft.com" , Kernel Hardening , Linux API , linux-arm-kernel , Linux FS Devel , linux-integrity , LKML , LSM List , Oleg Nesterov , X86 ML Subject: Re: [PATCH v1 0/4] [RFC] Implement Trampoline File Descriptor Message-ID: <20200802115600.GB1162@bug> References: <20200728131050.24443-1-madvenka@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! > > This is quite clever, but now I???m wondering just how much kernel help > > is really needed. In your series, the trampoline is an non-executable > > page. I can think of at least two alternative approaches, and I'd > > like to know the pros and cons. > > > > 1. Entirely userspace: a return trampoline would be something like: > > > > 1: > > pushq %rax > > pushq %rbc > > pushq %rcx > > ... > > pushq %r15 > > movq %rsp, %rdi # pointer to saved regs > > leaq 1b(%rip), %rsi # pointer to the trampoline itself > > callq trampoline_handler # see below > > For nested calls (where the trampoline needs to pass the > original stack frame to the nested function) I think you > just need a page full of: > mov $0, scratch_reg; jmp trampoline_handler I believe you could do with mov %pc, scratch_reg; jmp ... That has advantage of being able to share single physical page across multiple virtual pages... Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html