Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp794056pxk; Wed, 23 Sep 2020 16:55:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznUsEcTo1i8FouiUs5jIAGP1QXeatCy58JQP06B6ik2j6ZEzf5NBy6eb35Q6i9ekYJv6ME X-Received: by 2002:a17:906:9491:: with SMTP id t17mr1949000ejx.227.1600905346758; Wed, 23 Sep 2020 16:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600905346; cv=none; d=google.com; s=arc-20160816; b=pr1wS3ZDDvzrAu3TrlB9jjlGwUAWKJLFu3rBOWLVjtLzy1iKP9f3uulQieGVxYMvkX VBOhMgAp4RpFwKbZTi7W9pgfXCpdQuldHi/CeGgrjnewDmcmXamAIeD/xM0gxJHgU8mn 5j0+JiD9/rKabWnxw3G2c7utObfMiT60LDLXi/6OevoiHQCekfuSUVE5a0wEGBU6Xr4M rWozKaYqqVcrjQi7hJS2XoXeyXa+RpGYQU5B7g2KGjn25xJBTf9u42NksNItkjXWmLn3 3Hv9GYJFt3dXhLjqI4OGpyIDLwAjzdVCIYe5EIFFjmonyrYo7PdGSKEd3g8WFLtvrsxA 0G5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-filter; bh=stfW7VJ9ixikhAwpOM4Y5v+Co/aY6HnPcRI9MXRFn5o=; b=pNhxP34NdaAnKnci5mtFHxcXLC1yb1k4VK0e9yvmzFhyx6ixcxUFmdqm3M4m1OKB6F uj/c2FsBgvWjMryAcBfC8BDH7oa85t1wefz6jTivOV1V/nLN2VaJXYs8aAhpVtTOl6aF iaAMiGUSGiHg0iP59jSEEcAE2lpsRHCANryjREhoCq7jIEtZ//L4hsM6B7qoJDhYK750 +C9vhgtExEnvrGgOH6G71QDdp8/WAYNAkuboP5dRsIkrB5WTDo7PUZ5QJLJwyMPg2Ue9 8Zpx0hSuKClpZfkJdMapneOI4fH5HuYF6OM5Qg/egBT3pI+1oUkiBlKWkaUYs6lHi8zq Z/FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=XU8UVx4l; 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=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d6si870655ejp.629.2020.09.23.16.55.23; Wed, 23 Sep 2020 16:55: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=@linux.microsoft.com header.s=default header.b=XU8UVx4l; 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=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726711AbgIWXxY (ORCPT + 99 others); Wed, 23 Sep 2020 19:53:24 -0400 Received: from linux.microsoft.com ([13.77.154.182]:53714 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726466AbgIWXxX (ORCPT ); Wed, 23 Sep 2020 19:53:23 -0400 Received: from [192.168.254.38] (unknown [47.187.206.220]) by linux.microsoft.com (Postfix) with ESMTPSA id 035D320B7179; Wed, 23 Sep 2020 16:53:21 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 035D320B7179 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1600905202; bh=stfW7VJ9ixikhAwpOM4Y5v+Co/aY6HnPcRI9MXRFn5o=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=XU8UVx4l9QT/FMwo8coMBjnSlLBVk+KBoR6KrO3k/zZ6+mnhEd9ikKjXqtLLVZvX8 6L4k3p2sXtnrt7iHN48ZKcWMojIdvdW6wCunGopAI4Vm339QmzKeUGR7hpZh3q8OSK MOlqBqWNABhGiq2M7DKxely5hf7eFnDLY3+f4pu8= Subject: Re: [PATCH v2 0/4] [RFC] Implement Trampoline File Descriptor To: Florian Weimer , Solar Designer Cc: Pavel Machek , kernel-hardening@lists.openwall.com, linux-api@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, oleg@redhat.com, x86@kernel.org, luto@kernel.org, David.Laight@ACULAB.COM, mark.rutland@arm.com, mic@digikod.net, Rich Felker References: <20200922215326.4603-1-madvenka@linux.microsoft.com> <20200923081426.GA30279@amd> <20200923091456.GA6177@openwall.com> <87wo0ko8v0.fsf@oldenburg2.str.redhat.com> From: "Madhavan T. Venkataraman" Message-ID: <1a7c9989-fb98-20f7-c0d9-2261aa50d967@linux.microsoft.com> Date: Wed, 23 Sep 2020 18:53:21 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <87wo0ko8v0.fsf@oldenburg2.str.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/23/20 9:39 AM, Florian Weimer wrote: > * Solar Designer: > >> While I share my opinion here, I don't mean that to block Madhavan's >> work. I'd rather defer to people more knowledgeable in current userland >> and ABI issues/limitations and plans on dealing with those, especially >> to Florian Weimer. I haven't seen Florian say anything specific for or >> against Madhavan's proposal, and I'd like to. (Have I missed that?) > > There was a previous discussion, where I provided feedback (not much > different from the feedback here, given that the mechanism is mostly the > same). > > I think it's unnecessary for the libffi use case. Precompiled code can > be loaded from disk because the libffi trampolines are so regular. On > most architectures, it's not even the code that's patched, but some of > the data driving it, which happens to be located on the same page due to > a libffi quirk. > > The libffi use case is a bit strange anyway: its trampolines are > type-generic, and the per-call adjustment is data-driven. This means > that once you have libffi in the process, you have a generic > data-to-function-call mechanism available that can be abused (it's even > fully CET compatible in recent versions). And then you need to look at > the processes that use libffi. A lot of them contain bytecode > interpreters, and those enable data-driven arbitrary code execution as > well. I know that there are efforts under way to harden Python, but > it's going to be tough to get to the point where things are still > difficult for an attacker once they have the ability to make mprotect > calls. > > It was pointed out to me that libffi is doing things wrong, and the > trampolines should not be type-generic, but generated so that they match > the function being called. That is, the marshal/unmarshal code would be > open-coded in the trampoline, rather than using some generic mechanism > plus run-time dispatch on data tables describing the function type. > That is a very different design (and typically used by compilers (JIT or > not JIT) to implement native calls). Mapping some code page with a > repeating pattern would no longer work to defeat anti-JIT measures > because it's closer to real JIT. I don't know if kernel support could > make sense in this context, but it would be a completely different > patch. > > Thanks, > Florian > Hi Florian, I am making myself familiar with anti-JIT measures before I can respond to this comment. Bear with me. I will also respond to the above libffi comment. Madhavan