Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp945599pxp; Wed, 16 Mar 2022 22:12:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7d9AZkDUr8GLiJgLMlQsZzjDOPVbbE6VvsChQ1HMoGVHsluLfaFPx719gcxPkn7Np3adP X-Received: by 2002:a62:cfc6:0:b0:4f7:8d47:ed75 with SMTP id b189-20020a62cfc6000000b004f78d47ed75mr3140893pfg.5.1647493957292; Wed, 16 Mar 2022 22:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647493957; cv=none; d=google.com; s=arc-20160816; b=SsofbrDxk7Qt0HYc8voaZT7la22tSS35N9jWi3EJgWRwcQrFZBGWA0QSNJrQ8nCOdF erim4xNaU0BDq/PiseSDg1wjzI3E7igoU3+E2ek6V9ZvxC9gvxRxVJJFYIPkxITBoexU 9rFRIyvN/qNcLeHgpOYIiYB6UAv7phU+CxkrIVWuF3ptMIvfc4V/YrI+f0POPTvKgYXZ O8zHurMuK/tVc2zOl7N3711T6nAHgP8hQkcyhLjWcHKDrxnh7BvP0j6Kz7GyvGOwd/Fm rljPksAoHjk9zAxJ7Bzfs7bPPEDJXJQ9oHf3Td6hA5SLijU+ptIImZlvzPrk2G9IRR6W Lmew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=z/NYhpY6LxZSPy7ise3PwbolMR/KKjsJRtVBVWDkb/U=; b=an3zX114FSe3505Nw0LgQEdMKAzEWrL8gCfOUJwKaOK91tVvJuTMb5hC7Zf6WvS21O /MeB7ScE3ypSuqDTBx9ApU03ZspfkAuzNsfohhIa11cb6rDMZXytndMnho7kugLrwsgD hPiLqIAYnbKBMh9yGK2FO38bsh34zUqq8aPZeUH9kZpnMcNGWeopNibJfyf0jLCr5bSm T0ofaUSFEMttxYW5m9rKH0GwCYBDd0ZxJDU56Ulj+zLvUrXPlpyWg06bm4v5b/RlOmSn nMCQTGwntuqtY1uANpCYY+qZ+71uHKlfJcjeCNLZYsRZQfJEXnjOvIvdOtmNzAXKOWwG xKNg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id o17-20020a637311000000b003816043f08fsi1167168pgc.644.2022.03.16.22.12.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 22:12:37 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 804FB1DBA89; Wed, 16 Mar 2022 21:22:18 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355717AbiCPMkG (ORCPT + 99 others); Wed, 16 Mar 2022 08:40:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355682AbiCPMkE (ORCPT ); Wed, 16 Mar 2022 08:40:04 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6C5E5DA71 for ; Wed, 16 Mar 2022 05:38:49 -0700 (PDT) Received: from mail-wr1-f47.google.com ([209.85.221.47]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1N7zRz-1o89FU2NqF-0155A2 for ; Wed, 16 Mar 2022 13:38:47 +0100 Received: by mail-wr1-f47.google.com with SMTP id t11so2795904wrm.5 for ; Wed, 16 Mar 2022 05:38:47 -0700 (PDT) X-Gm-Message-State: AOAM531wIp8qG8Spq8RuPpZ2vzDJ0LhjUegm+j9BAyp8qOQrl69eMgf8 pmtR/M0sFibYLBNeDWUK/1P2YBwpDyvZ2fr/vgM= X-Received: by 2002:adf:f606:0:b0:203:8dff:f4ac with SMTP id t6-20020adff606000000b002038dfff4acmr21616253wrp.12.1647434327191; Wed, 16 Mar 2022 05:38:47 -0700 (PDT) MIME-Version: 1.0 References: <4c449fab-8135-5057-7d2c-7b948ce130cc@theinnocuous.com> <0b31b1d3-852d-6cab-82ae-5eecaec05679@theinnocuous.com> <202203151150.1CDB1D8DA@keescook> In-Reply-To: From: Arnd Bergmann Date: Wed, 16 Mar 2022 13:38:31 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86: Remove a.out support To: James Jones , Borislav Petkov , "the arch/x86 maintainers" , Linux Kernel Mailing List , Kees Cook Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:pf0qj805fGEiZiabT3YKBUNx+RSWSx5k7Gfoo17W26Yl3VvSdEk ScGXbmSRkMCR75OuGeowoXViiHzK+rMqV+vRIyJM+/0gSSKxdigvirblJ2Xjxb+6BWLtJ9U 1Z+SklEWvdXdfQSNR3haSJcY6rO+eJ+/+TU3jJAPmtcxKtwvdcRlaU8nMpd8LVT3stL9WsN igJpv8BumyacuRkIDL0cw== X-UI-Out-Filterresults: notjunk:1;V03:K0:oxcjxeQhLFE=:onE/TAh70/BHTU1XjSTgF3 4te12pJ0e2Q8my9GzMbX3P3C7Vptjhnh411ubbbPHAdfom6Z0rF9YZI7TSsJpp/FkRieIeBVi r9OWojEpJ2HKdJBq6/tl4bdnob1x0wRqIdKHG8bQ8yr35gId5NpHWfIMhqS9XTfeQJ+XN6F0F cSS9uy9zRISVMjvUr4Dqppdj2/9OHBUGnVgcd+pOraQ9KJOYCFyq/oQxtk3p5gHquolxFsgPK y/ZcFwey4J5gSyQ4LzNqgwEZkGj7BzAbZf7ZOctBig+3l6fD2gh3nC/sf4xUJ/17vYIIQln53 egCMXjaJOr4tzo/xIwI9o7z45AAObQzHiIxqqN80lws6W20gV+c2t8QOt1PkHwWMZB+VZTolw ePM4897540Qu6qbWRdlEkxCRp5iww203QostYFUlz2odqSAX64+4XVfJtLNZ9VHbTN2awu7bc S90gCRbXr7fw//eFV12vvXxjpe/fOY9IkCF8gZpV1aJ0B0sIVZjwDXcNYN4C7xbYPWglRdoay ci1IVsM8WD6oFxSQCn+5eoaIqi2DCH3kpltgw12hJz+j4rY6QRkj8h0d9AJc8rKTbrwb7HTvW iHHZ/b9EjjOPtF4hm+Q+gQx+56bXLEiZKH06s6JY284+bdBeqUcfKB4B7AJdkDc42IcgHWutD 3hMB+eEINnwTthhvx3hu6L9dhPBVlYHSbr2U/qloAEsLTruuj4N9oxyN4fLRdu7wHo3cUbRDz 829ubAqm9iep30b8lJb62xWe2IY56qXShYFOJ/vKvguDls5BNwzg32i9zf1yltK0iy+o7VDhS xUOomF3phAa5beUTj+XZgHpbwoXtWi3nQg+CgucecH452SY1sE= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 On Wed, Mar 16, 2022 James Jones wrote: > On 3/15/22 12:51 PM, Kees Cook wrote: > > Probably getting a bit off topic, but I did spend a few hours searching > around for any existing tools to convert a binary from a.out->ELF, and > trying to come up with something myself by extracting the sections with > objdump and re-combining them into an ELF using a linker script placing > the sections at the same locations. I couldn't get it working in an > evening or two messing with it so I moved on, but I agree something like > this seems possible in theory. I got 'mac' converted to an ELF that > would load up and print its input prompt if run without parameters, but > only if run as root. As a regular user, it segfaults somewhere before it > even starts executing in the text section AFAICT. Any actual assembling > segfaults even when running as root. I never got 'aln' to do anything > but segfault. > > I dug the scripts up in the state they were in when I gave up (September > 2020 according to mtime), and put them on github in case anyone wants to > have a go at it: > > https://github.com/cubanismo/aout-to-elf/ > > It was an interesting problem in its own right, and I'd be curious to > know what I missed. I noticed that qemu-user has code to run the two other native binary formats (elf and flat) that the kernel supports, in https://github.com/qemu/qemu/blob/master/linux-user/linuxload.c The qemu code is fairly close to the kernel version it is derived from, and the a.out loader in the kernel is the simplest of those. If performance is not overly important, I think it should be possible to turn the Linux binfmt_aout.c code into something that works in qemu, allowing you to run these executables through CPU emulation on any architecture. No idea how much work this is in the end, but it's likely easier than a standalone a.out loader in user space, or a conversion to ELF format. Arnd