Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5984385rdb; Sun, 17 Sep 2023 23:28:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3SyLnTYkleKAFvOThJIGmNp1LtGeVgAUVIm0y06eFiN9PmXMv9laltKFgP0+VyxyGFCgL X-Received: by 2002:a05:6a21:611:b0:13d:ac08:6b79 with SMTP id ll17-20020a056a21061100b0013dac086b79mr6794284pzb.60.1695018509846; Sun, 17 Sep 2023 23:28:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695018509; cv=none; d=google.com; s=arc-20160816; b=qykfrZBbphetBIQoNaiVm17Gq2NaZG+06ABvMm4RJLpUTqyxKSAEtk5vVXijAVeT2c /MWCRycmvB5zdKY3lmunwIRD3HE7jGVEtU+jPkpE0tC9HwWFXfZcCSGyAHYGJSkQzid6 +W7sg9kGtK4fV2RE1c3W/GVNLf85hYTe2cnXZ8q7NzOzpmCjJey+i5zAlkgYzNsK9AGW LgGBSr39ET1C6KxIGRR/P6J/aNAL4VX3lq2UqcfixCInTsS9gDgkXaaO5JIu+coj1RtI Giy0JifnjlKTYojRvu3zqNl0pvthQU0K/Bq3L4+kjVtDqv7MwKuWwR+mK1IsENagh6E8 qHPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=WEwkCJGeY11cl9r9Unf5IIsy7L/o8MIzT/3SYzzNTtk=; fh=g23dpoAOV22JEO76fRtvBYgskoJJWLAlJ3d5xOWwVhU=; b=umMtmk+wWwKofl0WVu06xG4NozMvx+4DrQCGrhK27B7NcSfjlXFwifyUv2/vi28iN4 DbYAqcKnbCi9afGpx77LPTmiIZ1qTDIji4qZFCLESUxDzdJUGNVvAG+3pKvzLvcFCIo3 0ZqdLKvKEbcPnj3y1QTvRsLs4BClK3CNNtfUWwW/qRfzeoeAdPznA/Zoh/WLR8KyBF0z tI8i63yoSUgz4ypup6qRjQWHuZdtVeCETXjSD7RQfN+2AlOcGoX+AVE0WVK5QnOYnTdU wLNZIX52FdEkywovPuNA0pJQZRcRbOv++oyM0Ik1ncJBZXqQXYrsLOvyDy5dMh5fyw1V vfzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g6mgy8yO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id cv8-20020a056a0044c800b0068ff9edf98asi7458178pfb.322.2023.09.17.23.28.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 23:28:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g6mgy8yO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 3A1AF80DCC9D; Sun, 17 Sep 2023 23:28:26 -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 S239821AbjIRG1l (ORCPT + 99 others); Mon, 18 Sep 2023 02:27:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239829AbjIRG1d (ORCPT ); Mon, 18 Sep 2023 02:27:33 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1949F8F; Sun, 17 Sep 2023 23:27:27 -0700 (PDT) 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-Spam-Status: No, score=-2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS 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 23:28:26 -0700 (PDT) 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