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 1D892CD37B0 for ; Mon, 18 Sep 2023 06:27:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 49D576B024F; Mon, 18 Sep 2023 02:27:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 44E786B0250; Mon, 18 Sep 2023 02:27:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3158A6B0251; Mon, 18 Sep 2023 02:27:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 201056B024F for ; Mon, 18 Sep 2023 02:27:32 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id DBDE4140B5E for ; Mon, 18 Sep 2023 06:27:31 +0000 (UTC) X-FDA: 81248736702.23.9D77F44 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf06.hostedemail.com (Postfix) with ESMTP id 01519180023 for ; Mon, 18 Sep 2023 06:27:29 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=g6mgy8yO; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.hostedemail.com: domain of gerg@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=gerg@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695018450; a=rsa-sha256; cv=none; b=qXpRwpb5VAsTg2s+fLKp8Wyb5voVcfxRX9K+b8YG12pwSSWAc4y8nvOrI3w/J0uEH/ETeT 36ruYNmQ4MtasDACNv2NJx7ktDxU+wExnkf04qQuOLtL0khSfrRsU72fkM+A+UjyYXnHIo iaVb0UzVUBqqmiZ4xjrOWuLv8GARcUA= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=g6mgy8yO; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.hostedemail.com: domain of gerg@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=gerg@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695018450; 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=WEwkCJGeY11cl9r9Unf5IIsy7L/o8MIzT/3SYzzNTtk=; b=gMRvysW6CAH0v6VRYvoiEUPwDfbJ52VvxxeJ8rd9pxeXkIt2UPvhbTSFkt28o4LVwq3s4w PezTHXVWtkZMo14UiNrpKW4Q87qimZfpzxcSzNHwzKv6LX4EyGliDHvNZyG6iEWrtGWp1B QhIbLKS+Ui9lZybOxfyd0ekUBTVT6ts= 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 ams.source.kernel.org (Postfix) with ESMTPS id 07706B80B2E; Mon, 18 Sep 2023 06:27:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C01DFC433C7; Mon, 18 Sep 2023 06:27:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695018446; bh=4QZJXtba7Bd/xM6MN6jVGiBfai/jz7oNBxLb0zxvHa8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=g6mgy8yOPCAhMnALuJZemFFcsH0ah+HMpfcpLv5DCdwHXX9W2+Y2pCjE35HZIMvw6 +IxsikCiEe2SiH9gQy+iRw7oH95vZlRGqKQKWnCXPyBWa77HpEtkiZ9e3Gc3LymGkT KiJPLeCtxULOuZFTy7+IBSy8nt1PUxntN2y1oHyqLRH/aPV5kXLv600J/JL67ybcej tKUd59T8GIdB1l+jKbM+e2A56nsfcbTKV0xRDOwTfJPL9T9GZrjHAFtG3q1mKJR/3+ P5C5UMJfxgeFEzZmtCm3UmTfg+RNL0KOe2r1XpU/uJUhjXy3lkO4kqxiGYTDPo1EMS UvtTL4HVRbgvg== Message-ID: <5573ef25-a35b-c189-874b-3cafba09b120@kernel.org> Date: Mon, 18 Sep 2023 16:27:22 +1000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH v2] fs: binfmt_elf_efpic: fix personality for ELF-FDPIC Content-Language: en-US To: Andrew Morton Cc: linux-arm@lists.infradead.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, keescook@chromium.org, ebiederm@xmission.com, brauner@kernel.org, viro@zeniv.linux.org.uk References: <20230907011808.2985083-1-gerg@kernel.org> <20230917122603.5466b1fc6d05ea9e9edee340@linux-foundation.org> From: Greg Ungerer In-Reply-To: <20230917122603.5466b1fc6d05ea9e9edee340@linux-foundation.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 01519180023 X-Stat-Signature: kyr33dxagnfo4w7qhhmtetexrswq9gp9 X-HE-Tag: 1695018449-848726 X-HE-Meta: U2FsdGVkX1+KZ9Is8Hr0xKefPcP/+v2yLNqnSsSH0HYXzFJF5VPaGKp/WC8tmucRtTws5cCDQAuskwc8xu/bHnp6fngNUvnFp9EgrA8P1xSO9wXq8umham0wdyP7+/FZNUP+pp98dp5sDg7OvcGx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RX//fjmT+qnMYtOQSurS3jEnZxVOilz8M3fZ4JJUOLPnPr5+uu2K5AEvUY0FXo/XVahJpp/dvoiylkARAPWorAHQFXfP7YW+0IHJLM5STccxN64mPtuVcx6Pl6xD6TipYydy1Rh7DxI653fDWyJL0N6aFyIED27bGS2iJWgKzC4U= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Andrew, On 18/9/23 05:26, Andrew Morton wrote: > 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: Yes, that seems reasonable. It will apply easily, and legitimately fix this specific issue going back to the original change. Regards Greg