Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5909994rdb; Sun, 17 Sep 2023 19:11:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2Af4rZMjAq1WUXhahudlW8L6Yd0NdT58u2SvkcFxrs0t22puYkBLf+/xSrRYo6Ur2DxE0 X-Received: by 2002:a17:902:6b01:b0:1c3:343c:f8b0 with SMTP id o1-20020a1709026b0100b001c3343cf8b0mr7786632plk.66.1695003064786; Sun, 17 Sep 2023 19:11:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695003064; cv=none; d=google.com; s=arc-20160816; b=DwI2nISpIeaU9QLpJoTyATk3TMy11MHijECWmxPFB4HqRxuQ9wzofQHrzjiJWLJ1DS SO41m7NQI6zWi9DgisuMJJRWv2lAtIe89iSLlZq7PbKtF9IB0rCpmjqS7QP9zwC09/2E 0EgNB4GR4yMpTRLtI6EuZhYT/pw61npkyFGYuNn6qkes7cOZ7Z0kAZtTeUrOsSQNXeJ/ nhMXT12zhpAsEhtMjVx6uueWatdGpAsS2tiE2UgVaJNstUfe9LPMYMbwl6tr0RI4+dQR uPYh3db6o++HLVgiKpCfeVm3/18xmw6oLgFIjexSwWb8/LCqLhZSqVe7BfSCc1kW9znn /ccA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=M3uGQyd6pOl+giXtQJfPdQQNi4Q7ot95iJEGF12w6D0=; fh=vsjbD+cxQ9IvwaXAsrJsHCLCfk1vJTqgxGcbJJ0Tzw0=; b=bLWGtztCefG6EXuU58fGuiv6z1mP5ZO+imVXmNnHKJ8SmJoqcwMQoN7IeCAvlPIVn1 F+inOsffoTCLFlb3EIdRGwJPPnhgig5vMmbyvqfCo+vuZIX6h7R3zHHEgDsOqDz1g4jq /z7roEJbIhm02hi7UUWBY1MHfGkjSf7iDX/yzmY1D5IgvGNrfquQVRxCJo8l7Hs5tU/m L89MUxJKlkLeb74nN8qqYcz1pj9kUqn23LQCbinEMFND73HyEsIvJOA1tkHBTol5qodX xeIBoAWeYv5x8XQT6Lvfn5xeYmkTAeRqe/q1AiuPWeY3d7VC8Oicikhbmz3m9BogqJki Knxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="dw/Qwm4n"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id z13-20020a1709027e8d00b001bba4470991si844239pla.498.2023.09.17.19.11.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 19:11:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="dw/Qwm4n"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 7E5AD8106F6F; Sun, 17 Sep 2023 12:26:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239538AbjIQT0X (ORCPT + 99 others); Sun, 17 Sep 2023 15:26:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239698AbjIQT0M (ORCPT ); Sun, 17 Sep 2023 15:26:12 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F9E3119; Sun, 17 Sep 2023 12:26:05 -0700 (PDT) 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-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sun, 17 Sep 2023 12:26:57 -0700 (PDT) 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: ?