Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp2102590rwb; Sun, 6 Aug 2023 09:49:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtQlYM9SOaG6aOHVycQv/9xTY1tjcnA4K7dOd5utNmXmcSvkblNj8mrWK9ybX95jlfdJ1G X-Received: by 2002:a05:6a20:258b:b0:133:7ad8:712b with SMTP id k11-20020a056a20258b00b001337ad8712bmr8401708pzd.52.1691340573754; Sun, 06 Aug 2023 09:49:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691340573; cv=none; d=google.com; s=arc-20160816; b=ZKYpbRrdKSlUrUKjTOoXsIRBjV+Ht6DBSFjVVQoYnXLpI+e+I/1TwEoK37lFEGOH6j 7in0KhkIQCGf04SAFqaRTVh8/zMTWAQ3X0F56vldWA6WE4Umm0ctII4adrPXrBAMwabn usshY194aLLhTe4RrZQgCwR7edYEkdd96rbMidlhRit/dKk0OH3xeH4dA0EZEoZ4ywMN zn7zFyv/l5AiNeY8k2p9lwXW9oc2Td4+Vjq47Fv7AiM+uhdiQk1+q+2vowlUwFurQPoF 5vC4oRVGFojW+FOFQNasef5C6fyd2lHy39voA0xdrobeY+B80ijnEQ/A+4XfPHm1rVmC PnZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Lnwm/mc+XxmmLSXiER3Pgnk2IR8GvbHg5YZUfrsA8hA=; fh=Tr+d/UgGTrmtx3HQC5ItOFlbcKzGHae8iExsWeIN65Y=; b=i5ocE5C5vmwS9SJZMwL+MSoSKPiq3TFnnBWCF1U5Ikuszj57S8KdL6Xqt91zZkUJCl f2LuB/YK01HZvgC12A44pH5YMsdL2axa4sP34DBRufAzGrEOtoDEFVCCX9sCaSVpILZF r+HTXwewYSBw0jPwXMolp86N6r35XsDftBmMtBz1TsObc78Q6HhzE6eQtoywaCaF5CqJ VePyHkxHVU4twqxGqr/Cz9P0YdmwrZ/QFTjQpfpmSL+CiGQmE+xL/SO+tfshZcDzEPV6 U11os8pnKdS4ExYyeGDoET1wpd6P0SQQUMv7ltF3zUx96YN9BO0NRIS0NI3LjJGei2h0 9Ypg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lHl824MQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a6564c8000000b0056385704942si4453521pgv.595.2023.08.06.09.49.22; Sun, 06 Aug 2023 09:49:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lHl824MQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229993AbjHFQXx (ORCPT + 99 others); Sun, 6 Aug 2023 12:23:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjHFQXw (ORCPT ); Sun, 6 Aug 2023 12:23:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA375113 for ; Sun, 6 Aug 2023 09:23:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 350B461035 for ; Sun, 6 Aug 2023 16:23:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A5B4C433C8; Sun, 6 Aug 2023 16:23:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691339029; bh=WvFbeGSja2fHMrxL2gi9+8yw0glACJgkp0g0wx3S3X8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lHl824MQUgGjsskvmnR12XTxpi0jiVMNlZjh7ntIn+BFtzVz4rfT9hNRdDqe/67GC Nu5jkNTL2uDrLtaDP/76/Zt7JxzfmNci3FeVjPWCCqBS3KRoLaoI9kxfx1fWRe1bDq 7uoCewZ2DQUQjTcTxHBFUicazxePi7Sovf0xGlvr+t+nR1lEWTptBFwwbyVnryWRoJ /sXh1HGB21hosXGkSWH/ZGFUskEFrEyetxv+x7FqKym2lM5jroFn+Kx5jTgHHm/5aN 5U72pnwST8yHaIMxpERNWpZXGbe7LWd0hKE8iw0qrsIS6NdVjw9IunBXd9ZnSv7HG7 rcgfdE6bHGMUw== Received: by pali.im (Postfix) id EB6E280E; Sun, 6 Aug 2023 18:23:46 +0200 (CEST) Date: Sun, 6 Aug 2023 18:23:46 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Eric Biederman , Kees Cook Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: binfmt_misc & different PE binaries Message-ID: <20230806162346.v7gjoev2nepxlcox@pali> References: <20230706115550.sqyh3k26e2glz2lu@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230706115550.sqyh3k26e2glz2lu@pali> User-Agent: NeoMutt/20180716 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, I would like to remind this email about binfmt_misc for PE. On Thursday 06 July 2023 13:55:50 Pali Rohár wrote: > Hello, > > I would like to ask how to properly register binfmt_misc for different > PE binaries, so kernel could execute the correct loader for them. > > I mean, how to register support for Win32 (console/gui) PE binaries and > also for CLR PE binaries (dotnet). Win32 needs to be executed under wine > and CLR ideally under dotnet core (or mono). > > I have read kernel documentation files admin-guide/binfmt-misc.rst > and admin-guide/mono.rst. But seems that they are in conflicts as both > wants to registers its own handler for the same magic: > > echo ':DOSWin:M::MZ::/usr/local/bin/wine:' > register > > echo ':CLR:M::MZ::/usr/bin/mono:' > /proc/sys/fs/binfmt_misc/register > > Not mentioning the fact that they register DOS MZ handler, which matches > not only all PE binaries (including EFI, libraries, other processors), > but also all kind of other NE/LE/LX binaries and different DOS extenders. > > From documentation it looks like that even registering PE binaries is > impossible by binfmt_misc as PE is detected by checking that indirect > reference from 0x3C is PE\0\0. And distinguish between Win32 and CLR > needs to parse PE COM descriptor directory. > > Or it is possible to write binfmt_misc pattern match based on indirect > offset?