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=-5.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 82E16C433DF for ; Sun, 2 Aug 2020 11:56:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6595B207DF for ; Sun, 2 Aug 2020 11:56:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728211AbgHBL4L (ORCPT ); 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-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@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