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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9BA8CD37B4 for ; Sun, 17 Sep 2023 19:26:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 13D746B01AA; Sun, 17 Sep 2023 15:26:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C6EA6B01AE; Sun, 17 Sep 2023 15:26:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EAA856B01B1; Sun, 17 Sep 2023 15:26:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D6F386B01AA for ; Sun, 17 Sep 2023 15:26:13 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 9DC861A0A7D for ; Sun, 17 Sep 2023 19:26:13 +0000 (UTC) X-FDA: 81247070226.03.2B1818E Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf20.hostedemail.com (Postfix) with ESMTP id 7C8EA1C0022 for ; Sun, 17 Sep 2023 19:26:11 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="dw/Qwm4n"; dmarc=none; spf=pass (imf20.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694978772; h=from:from:sender: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:dkim-signature; bh=M3uGQyd6pOl+giXtQJfPdQQNi4Q7ot95iJEGF12w6D0=; b=HCtWYm/s6JYnSr2EgZYOa1kaJxCHyVP/Co2g0HET6KHz3zifpEZbcOjflS2kElJbBhm/5h yHWWvE6eWNsfwMj725qLo372zYR3FQTGbYgYcYYNOpov9HuxrtDEZJ8C+tTQfLBf9eYzzQ k94DqOdBXfo2TfnJPamEWc86WY0ZOOM= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="dw/Qwm4n"; dmarc=none; spf=pass (imf20.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694978772; a=rsa-sha256; cv=none; b=xQGZ3cn/4ng/gS62ClMC8Ex/pOPnrkubn2wL4ZPSv2d9k0SRm7ll1UR+VOiAUZR2MNZulH /CPD3hXDrNQix8YahCNMZD3vK6B3qRxuUpq2q1ptlLJ1x5MWb1mnRHPjvdoxla9zVbbZV4 ItaOOzJMj/TEJWJs6knfeT77Z6hq+90= 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 sin.source.kernel.org (Postfix) with ESMTPS id B24EFCE0ADF; Sun, 17 Sep 2023 19:26:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B67ADC433C9; Sun, 17 Sep 2023 19:26:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1694978765; bh=bZIPkQ41DTNfms13oHVUudCcifvu53l1vSPYEk6CNI8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=dw/Qwm4nEGzgoowEvZPGuy9vyHCeJLvQ7jF4t+RHH6VwhUcaqUj8SoZJ5yGYHVH3v Q3RQ5T+kHkyBA7vHBciqBmUXeNnZDdsgyxsFtUEbFqfXZRKoizTSItoyeCqoA52XE9 lL5PwulK261xed0NKEX78vAedm4WVdHOTgOVaVo4= Date: Sun, 17 Sep 2023 12:26:03 -0700 From: Andrew Morton To: Greg Ungerer Cc: linux-arm@lists.infradead.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, eescook@chromium.org, ebiederm@xmission.com, brauner@kernel.org, viro@zeniv.linux.org.uk Subject: Re: [PATCH v2] fs: binfmt_elf_efpic: fix personality for ELF-FDPIC Message-Id: <20230917122603.5466b1fc6d05ea9e9edee340@linux-foundation.org> In-Reply-To: <20230907011808.2985083-1-gerg@kernel.org> References: <20230907011808.2985083-1-gerg@kernel.org> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspam-User: X-Stat-Signature: k9u75mscjtpcttpiq69ahe8eafffuzmz X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7C8EA1C0022 X-HE-Tag: 1694978771-317532 X-HE-Meta: U2FsdGVkX1/em3nhB259Vyf+2EZneaQxWKGWKv9L9PUFMLhLLVwTUh2VU0aL8BtCTYsmwo0RTm1Y58M+A2DgobpmbUwHzLOqN2C7Du6TmvVhtDJtglIgtqY1hijVC9jXAOXBWFESKu7Iub7coDIpFLDiNBqv75RxPFqoct4cny6v5B9DK0/5iKLSdbuzOQrANGbBKFpRDfB+cZBILrtdnXkUZGbCxxkenYzBCRA8nnYHQDR9QqzikDSxUp3eOeSieJHpTAAU4qEXdZtJBMd+fG3T7GiZYQEbhXZOnG3yiNfT+81a26AHfStIvW3yktBxAqqMV3w5P7AXoHRhkTyZHpVpUnXqBoPLa1s7NqB3H1UF7PEtZ3XpZTTctQnUG8XyXo+yyMPc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=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, 7 Sep 2023 11:18:08 +1000 Greg Ungerer wrote: > The elf-fdpic loader hard sets the process personality to either > PER_LINUX_FDPIC for true elf-fdpic binaries or to PER_LINUX for > normal ELF binaries (in this case they would be constant displacement > compiled with -pie for example). The problem with that is that it > will lose any other bits that may be in the ELF header personality > (such as the "bug emulation" bits). > > On the ARM architecture the ADDR_LIMIT_32BIT flag is used to signify > a normal 32bit binary - as opposed to a legacy 26bit address binary. > This matters since start_thread() will set the ARM CPSR register as > required based on this flag. If the elf-fdpic loader loses this bit > the process will be mis-configured and crash out pretty quickly. > > Modify elf-fdpic loader personality setting so that it preserves the > upper three bytes by using the SET_PERSONALITY macro to set it. This > macro in the generic case sets PER_LINUX and preserves the upper bytes. > Architectures can override this for their specific use case, and ARM > does exactly this. > > The problem shows up quite easily running under qemu using the ARM > architecture, but not necessarily on all types of real ARM hardware. > If the underlying ARM processor does not support the legacy 26-bit > addressing mode then everything will work as expected. I'm thinking Fixes: 1bde925d23547 ("fs/binfmt_elf_fdpic.c: provide NOMMU loader for regular ELF binaries") Cc: ?