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 2ACE8C433E3 for ; Sun, 2 Aug 2020 11:56:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F244D2075B for ; Sun, 2 Aug 2020 11:56:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728231AbgHBL4M (ORCPT ); Sun, 2 Aug 2020 07:56:12 -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 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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 7481CC433E0 for ; Sun, 2 Aug 2020 11:57:32 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 419902075B for ; Sun, 2 Aug 2020 11:57:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="z+vdPYaV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 419902075B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=QGh7+c4/D8dha/Esn+/medp+YptrzmHFzzUOdR4LnVY=; b=z+vdPYaVj6ebv3P8qf07y4o+R 6BDX3ugSuQQgZjiEYubF5mbV4HwlvMv634owaLD/28AOuvWfmjbQrUzURxXG1Ip6ByjlRmOQsRGRg XnmXI6zYVYcitSduHW0sp97xN32bhdo5ZesVjv8nVje+Zspiiss1JQS82ncIn+zcVAtr2J+Ki/zPn R2uEIxwOsYFwbciE9UEy8dCbqz7UherBEQ1wC+qQestUz1qeEC45JpkhE9l9SI0gvP1AI4tzM7Qhw 8WOfHLT1mlLCWw2FMxJy2LZqtqVf6BLePIsux78gs8aiaI/0IYAvarBSbmKMcdoPN2t4eP7GYodij YZOY2jn8Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2Cb6-0000bn-Rt; Sun, 02 Aug 2020 11:56:12 +0000 Received: from jabberwock.ucw.cz ([46.255.230.98]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k2Cb3-0000bD-Sg for linux-arm-kernel@lists.infradead.org; Sun, 02 Aug 2020 11:56:10 +0000 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 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-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200802_075610_073694_2754DE2D X-CRM114-Status: GOOD ( 13.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kernel Hardening , Linux API , X86 ML , LKML , Oleg Nesterov , "madvenka@linux.microsoft.com" , LSM List , 'Andy Lutomirski' , Linux FS Devel , linux-integrity , linux-arm-kernel Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel