Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp216051rdb; Fri, 6 Oct 2023 00:52:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHCk6IBLBOLASl+rXydwsA4lOmhNFMlg73e9KarDwMMb97qo0Px+6p4tEPS4B2G8xbcGsTD X-Received: by 2002:a05:6a00:17a1:b0:690:c1a6:1c3b with SMTP id s33-20020a056a0017a100b00690c1a61c3bmr7848107pfg.33.1696578749536; Fri, 06 Oct 2023 00:52:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696578749; cv=none; d=google.com; s=arc-20160816; b=mTQAfuDt0MjGUzx6WNveCljOE66lmGY95FGZ7e26WYuGsQDiFmxiS5CU0Rw9C4Q7yE DSDB0lhpW9Tp3EfkfEfly7UmnYR+pyv9OIZfebKdmkHTBcSFWKZl9mPSXXkK+ChX/7xi L6lTaBM6/igO90Zl7WNXfONfUAm0aIkTrtA3U+d1YrlobW3sOEq4jx3nhzRb2qBMAAG1 R6EjrHlbvs6Oy+jw/OippHnSIP/Hna5/Q5Qdfrydw4uS6O4pRvnxK7Nz2u38pLae28yc Z6sFR8APtdR7wi583Jc39J9fifTL1eoHlLyVLLLdhmha10JOKbL0Xcjxl5FyeZC6xINN +KLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=iuK03HmNqgCaa8FhOu7IDj+wgutL2t54fgRlwMCc6iw=; fh=YVjLsiFcMLJoC0uDGV65OcP1oSIJZTsLW1WfBpi294I=; b=B6zlUbYnz3KknwdxKlksgkEYBztBezr3MmWQ/cd+uuT/OX2IZEA4qKD/sJDr7FwWDs 0sGFQZHEMSjvAZIKkrQsw5YbWntmtEjeN8mQ54KG2pQIFks9wsuAH3ZggShr6pogNh1m uMuxlIStSRsYOZ1wvkc2rYA8eMwNN7DqoCQyOOduTfXEGuZKdpbcRD4Px2QFRuHw6e/R u1runMSk86YA+elMn98Ct5fLoezUmzjt10aQlOKO70cK75KZCsmQXpt9U6YqHXurgk/L FYtbkSbWtOCSuzyVqbObOg1xeAbnJU4FpCOAt8kCYW2WPLRGpPIgGwj4To7pbENtcGaC C8VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=kNuCrFaW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id w70-20020a638249000000b005775a4a2960si3108541pgd.261.2023.10.06.00.52.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 00:52:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=kNuCrFaW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 332488072A3B; Fri, 6 Oct 2023 00:52:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230383AbjJFHvu (ORCPT + 99 others); Fri, 6 Oct 2023 03:51:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230437AbjJFHvo (ORCPT ); Fri, 6 Oct 2023 03:51:44 -0400 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D14A1F1; Fri, 6 Oct 2023 00:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=iuK03HmNqgCaa8FhOu7IDj+wgutL2t54fgRlwMCc6iw=; b=kNuCrFaW39RlsEpKJf9vOpPzHH zG02syRAUaeEW3/ocBPYR5/3Azpku/r4b9FBl+74anGSuXuNQ6AoLh4GMMZ2fvw0yun0XQvMwNe7J abBUjM8Y8SqAsG+/wp5xZx3VomD6AWyfmfoiNHZNpUfUQdlaSpGcfiNvlK+K4GPR08q2XbxsgV88u xH6OLHi34c0g7LmuTmvQ1I5TAL9rvKbJzaQgQ5nJt7d/m7ePqokcqfk8y9L7WP4gHwh/S9hz2oTBP jYjqDD7KgSnBw7BftXI1jZcwGXIrPqG3xbCAU4RXwDi6x8LWigcrWPqO/Dt5MmW3Ui4OsfYMfCRas OXgWUSuA==; Received: from cpe90-146-105-192.liwest.at ([90.146.105.192] helo=[192.168.178.99]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim) id 1qofcU-00CTMq-7L; Fri, 06 Oct 2023 09:51:34 +0200 Message-ID: <31021a6a-4238-5fb0-45a9-2ea95d6b73e7@igalia.com> Date: Fri, 6 Oct 2023 09:51:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [RFC PATCH 0/2] Introduce a way to expose the interpreted file with binfmt_misc Content-Language: en-US To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org, kernel-dev@igalia.com, kernel@gpiccoli.net, keescook@chromium.org, ebiederm@xmission.com, oleg@redhat.com, yzaikin@google.com, mcgrof@kernel.org, akpm@linux-foundation.org, brauner@kernel.org, viro@zeniv.linux.org.uk, willy@infradead.org, david@redhat.com, dave@stgolabs.net, sonicadvance1@gmail.com, joshua@froggi.es References: <20230907204256.3700336-1-gpiccoli@igalia.com> From: "Guilherme G. Piccoli" In-Reply-To: <20230907204256.3700336-1-gpiccoli@igalia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 06 Oct 2023 00:52:03 -0700 (PDT) On 07/09/2023 22:24, Guilherme G. Piccoli wrote: > Currently the kernel provides a symlink to the executable binary, in the > form of procfs file exe_file (/proc/self/exe_file for example). But what > happens in interpreted scenarios (like binfmt_misc) is that such link > always points to the *interpreter*. For cases of Linux binary emulators, > like FEX [0] for example, it's then necessary to somehow mask that and > emulate the true binary path. > > We hereby propose a way to expose such interpreted binary as exe_file if > the flag 'I' is selected on binfmt_misc. When that flag is set, the file > /proc/self/exe_file points to the *interpreted* file, be it ELF or not. > In order to allow users to distinguish if such flag is used or not without > checking the binfmt_misc filesystem, we propose also the /proc/self/interpreter > file, which always points to the *interpreter* in scenarios where > interpretation is set, like binfmt_misc. This file is empty / points to > nothing in the case of regular ELF execution, though we could consider > implementing a way to point to the LD preloader if that makes sense... > > This was sent as RFC because of course it's a very core change, affecting > multiple areas and there are design choices (and questions) in each patch > so we could discuss and check the best way to implement the solution as > well as the corner cases handling. This is a very useful feature for > emulators and such, like FEX and Wine, which usually need to circumvent > this kernel limitation in order to expose the true emulated file name > (more examples at [1][2][3]). > > This patchset is based on the currently v6.6-rc1 candidate (Linus tree > from yesterday) and was tested under QEMU as well as using FEX. > Thanks in advance for comments, any feedback is greatly appreciated! > Cheers, > > Guilherme > > > [0] https://github.com/FEX-Emu/FEX > > [1] Using an environment variable trick to override exe_file: > https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/util/u_process.c#L209 > > [2] https://github.com/baldurk/renderdoc/pull/2694 > > [3] FEX handling of the exe_file parsing: > https://github.com/FEX-Emu/FEX/blob/main/Source/Tools/FEXLoader/LinuxSyscalls/FileManagement.cpp#L499 > > Hi folks, gentle monthly ping. Any opinions / suggestions on that? Thanks in advance, Guilherme