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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A2D7C4332F for ; Mon, 13 Nov 2023 19:18:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232154AbjKMTSn (ORCPT ); Mon, 13 Nov 2023 14:18:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232214AbjKMTSZ (ORCPT ); Mon, 13 Nov 2023 14:18:25 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECB8A49C2 for ; Mon, 13 Nov 2023 11:16:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699903015; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=QI+OFjhz2/q8YuzQGF/7kt5ZmFWZ0Ih26v8XHGpxDAg=; b=fLRQ8wPKd2W7FbGiozSgw3RjYwBhpsqHT7o00u5ltP0iLZVrhRqyDZU8U9fQ+qotiqIZlV SiYlHGm7o2SGX9IFnEaPXeUjPMVI0eOzLsQpMHkDdiuwn6q+v5ZLe/kRPn4EQQDD8tReNO wt1rD6zIcHatuHtRCffXRYYias+JZIk= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-335-Xc6N2cjSN9mU2fTCG_dqQQ-1; Mon, 13 Nov 2023 14:16:53 -0500 X-MC-Unique: Xc6N2cjSN9mU2fTCG_dqQQ-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-408524e2368so31927625e9.0 for ; Mon, 13 Nov 2023 11:16:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699903012; x=1700507812; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=QI+OFjhz2/q8YuzQGF/7kt5ZmFWZ0Ih26v8XHGpxDAg=; b=F7yfU2ZvjmAfyO6o67MActqusymnmNNmhfWXkUJ5+qjxnVNpQDlKTonRC7pe42ssm4 N6whV/WsD8Na3AN4SzYtPfGnBcQTc0K+Hhgc19/If31MSTWqJmFPiaH8z6G9vMRHg67q Mls9/4vYLn7VcwHjW81ytw16tp4a21BLcyYPH7rRYlJDTuzqvrXkfneZD4ry4nZk93RU 8hPxhAbH8oJD6bJK5KhgHo71RdvJQlHo8biJuvXYiEb7latA5vLSk2H9Mb1OOZLpPFQR XZjNBWssKNgELf83sqGHw6XH/+FdUDCdMl75kBs41QoXItvuYhP4sBgRPkPOaQ+uY+iM ZW2w== X-Gm-Message-State: AOJu0YwYAiLPLJ2UkWIbGQePvqwTscLIVZp+xLiBdlQo91UUMiK3ZgNH y4b5ZtK/9CTacFgX3g3x4jXOkKLtjnBGKT0nXtapNg5sMNl7h8ARt6vcPDNxxFnELVAPd19VAeS 6kkiyrecMc9WCR+ypKFg/gsX6 X-Received: by 2002:a5d:5847:0:b0:32f:7d5a:87ab with SMTP id i7-20020a5d5847000000b0032f7d5a87abmr6576520wrf.53.1699903012062; Mon, 13 Nov 2023 11:16:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IHePviOiZUmhfcxNssCAgAnAuSKXuz27fg99dUJ3dKUcuVnbQ/fIU7ew3IR4gby02/E8lMFlQ== X-Received: by 2002:a5d:5847:0:b0:32f:7d5a:87ab with SMTP id i7-20020a5d5847000000b0032f7d5a87abmr6576498wrf.53.1699903011617; Mon, 13 Nov 2023 11:16:51 -0800 (PST) Received: from ?IPV6:2003:cb:c73a:400:892e:7ff0:87:a52c? (p200300cbc73a0400892e7ff00087a52c.dip0.t-ipconnect.de. [2003:cb:c73a:400:892e:7ff0:87:a52c]) by smtp.gmail.com with ESMTPSA id w12-20020a5d544c000000b0031aef72a021sm6020406wrv.86.2023.11.13.11.16.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Nov 2023 11:16:51 -0800 (PST) Message-ID: <9f83d97e-b7a1-4142-8316-088b3854c30d@redhat.com> Date: Mon, 13 Nov 2023 20:16:49 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 0/2] Introduce a way to expose the interpreted file with binfmt_misc Content-Language: en-US To: "Eric W. Biederman" , "Guilherme G. Piccoli" Cc: Kees Cook , sonicadvance1@gmail.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, kernel-dev@igalia.com, kernel@gpiccoli.net, oleg@redhat.com, yzaikin@google.com, mcgrof@kernel.org, akpm@linux-foundation.org, brauner@kernel.org, viro@zeniv.linux.org.uk, willy@infradead.org, dave@stgolabs.net, joshua@froggi.es References: <20230907204256.3700336-1-gpiccoli@igalia.com> <202310091034.4F58841@keescook> <8dc5069f-5642-cc5b-60e0-0ed3789c780b@igalia.com> <871qctwlpx.fsf@email.froward.int.ebiederm.org> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0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MOkYN/MpN3hD3 AP+DWgUCXw7HsgUJEqkpoQAKCRBN3hD3AP+DWrrpD/4qS3dyVRxDcDHIlmguXjC1Q5tZTwNB boaBTPHSy/Nksu0eY7x6HfQJ3xajVH32Ms6t1trDQmPx2iP5+7iDsb7OKAb5eOS8h+BEBDeq 3ecsQDv0fFJOA9ag5O3LLNk+3x3q7e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <871qctwlpx.fsf@email.froward.int.ebiederm.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13.11.23 19:29, Eric W. Biederman wrote: > "Guilherme G. Piccoli" writes: > >> On 09/10/2023 14:37, Kees Cook wrote: >>> On Fri, Oct 06, 2023 at 02:07:16PM +0200, David Hildenbrand wrote: >>>> On 07.09.23 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. >>>> >>>> I'm absolutely no expert on that, but I'm wondering if, instead of modifying >>>> exe_file and adding an interpreter file, you'd want to leave exe_file alone >>>> and instead provide an easier way to obtain the interpreted file. >>>> >>>> Can you maybe describe why modifying exe_file is desired (about which >>>> consumers are we worrying? ) and what exactly FEX does to handle that (how >>>> does it mask that?). >>>> >>>> So a bit more background on the challenges without this change would be >>>> appreciated. >>> >>> Yeah, it sounds like you're dealing with a process that examines >>> /proc/self/exe_file for itself only to find the binfmt_misc interpreter >>> when it was run via binfmt_misc? >>> >>> What actually breaks? Or rather, why does the process to examine >>> exe_file? I'm just trying to see if there are other solutions here that >>> would avoid creating an ambiguous interface... >>> >> >> Thanks Kees and David! Did Ryan's thorough comment addressed your >> questions? Do you have any take on the TODOs? >> >> I can maybe rebase against 6.7-rc1 and resubmit , if that makes sense! >> But would be better having the TODOs addressed, I guess. > > Currently there is a mechanism in the kernel for changing > /proc/self/exe. Would that be reasonable to use in this case? > > It came from the checkpoint/restart work, but given that it is already > implemented it seems like the path of least resistance to get your > binfmt_misc that wants to look like binfmt_elf to use that mechanism. I had that in mind as well, but prctl_set_mm_exe_file()->replace_mm_exe_file() fails if the executable is still mmaped (due to denywrite handling); that should be the case for the emulator I strongly assume. -- Cheers, David / dhildenb