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 94182E77197 for ; Thu, 9 Jan 2025 16:52:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC3B76B0085; Thu, 9 Jan 2025 11:52:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B73B46B0088; Thu, 9 Jan 2025 11:52:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A14306B0089; Thu, 9 Jan 2025 11:52:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 84FA16B0085 for ; Thu, 9 Jan 2025 11:52:45 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0CE3D1C6A0D for ; Thu, 9 Jan 2025 16:52:45 +0000 (UTC) X-FDA: 82988507490.28.4D15131 Received: from fout-b2-smtp.messagingengine.com (fout-b2-smtp.messagingengine.com [202.12.124.145]) by imf19.hostedemail.com (Postfix) with ESMTP id CFB001A000A for ; Thu, 9 Jan 2025 16:52:42 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=arndb.de header.s=fm1 header.b=gOTKsWAv; dkim=pass header.d=messagingengine.com header.s=fm2 header.b="D LvVmNV"; spf=pass (imf19.hostedemail.com: domain of arnd@arndb.de designates 202.12.124.145 as permitted sender) smtp.mailfrom=arnd@arndb.de; dmarc=pass (policy=none) header.from=arndb.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736441563; 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=/rcKcUgOCZt40Un+pkihZ5X0Uu+7S4RKKMTZS1cf54U=; b=h3Z9lJm/l7dRJw8OLv33TZZEGb2Gzph+xxrEWbuslXjhXV5VT0h7LfRdU7tJpDzGqL+UHw pABUa6/PnoqaOgJ+AL4RcX7tVCi6nL7XCE3Pcd7ogVuuRQC/DFg/NWcsm5mjSpjZSrBsoP wYuyC0UsICRm/VjtohN6/AlncUU1kG4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736441563; a=rsa-sha256; cv=none; b=ZrXqat/kHVCqKEBX5maABZXNZQVXxjuKUM6OqEArHeaO0C9LP/WvMKRQhjz5UjCl3eFnWy B23sxQi6SwcMVySQ4utXPfhiirYltgelvjp44Q+hbbEj+UUf69KVkv1L12EfV67cSVTwRb dyi9mTncmKMG+tT9X+o/uZI5LBK/V9Y= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=arndb.de header.s=fm1 header.b=gOTKsWAv; dkim=pass header.d=messagingengine.com header.s=fm2 header.b="D LvVmNV"; spf=pass (imf19.hostedemail.com: domain of arnd@arndb.de designates 202.12.124.145 as permitted sender) smtp.mailfrom=arnd@arndb.de; dmarc=pass (policy=none) header.from=arndb.de Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.stl.internal (Postfix) with ESMTP id 72DED1140137; Thu, 9 Jan 2025 11:52:41 -0500 (EST) Received: from phl-imap-11 ([10.202.2.101]) by phl-compute-10.internal (MEProxy); Thu, 09 Jan 2025 11:52:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1736441561; x=1736527961; bh=/rcKcUgOCZt40Un+pkihZ5X0Uu+7S4RKKMTZS1cf54U=; b= gOTKsWAvZ1JEALHrwD/oajJGGxAcx2U/RSOyBlM8m+cHfL5IEyEqXSDdRHm10huj vqyfZHkgoOpSMt1LVLFKEG3O/l+wzre9xJxQSRFff6cD2QdmCcWoBCkmmIVzlZV7 9JMH37sR7cFSdrcczqkiSA+/eZHkbt1dDLsBGimqn/NkbNjGbjUNkmOUSgYg7O1c BmzcI/5NSzuCAwmDA8x46RXBKrwSGFxsFcoQ1gvw5RmLvz39Ws5TqLmZHAfBH1df kXs1058mtncX1v8ksZ//WTMeAvXmc+KU3nWFBsjBOyjpZsq6sI6T+u+GgGaYMwPc Li8OlGseAVR0KZK6hn9fdQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1736441561; x= 1736527961; bh=/rcKcUgOCZt40Un+pkihZ5X0Uu+7S4RKKMTZS1cf54U=; b=D LvVmNVmSLnLjGstioKiE6GNIH7n48D8d7QeqviiRaTqI8dmZKwHpm84ExKPwnZ+q 7JZl5d5RC4nvK+jEwPD0cafJcqisdN/aD+fXkbXHddkvpIGW56Crc9RfV3RPB4Kr hZ7KR8q7Nuo51zN/tft2F39Lzu6LesJ+fHSR4VvUGvH4Gs90I/hN5HD7g25VjHVc KhaaJRC4uhSNzBoZuNHuUwEPTauRJj2YwvynYhJGCl3oExZq8VU5faLFfrjajKWN s/Xe/9AuqSbQcTqLKimhnkv1pLP3btobq0mCbWBDJeooN06/aC7Ep41Bv3Wchncp d3CWy9RwO/ytOXmrSP26A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudegiedgleduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepofggfffhvfevkfgjfhfutgfgsehtjeertdertddt necuhfhrohhmpedftehrnhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrd guvgeqnecuggftrfgrthhtvghrnhephfdthfdvtdefhedukeetgefggffhjeeggeetfefg gfevudegudevledvkefhvdeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheprghrnhgusegrrhhnuggsrdguvgdpnhgspghrtghpthhtohepudek pdhmohguvgepshhmthhpohhuthdprhgtphhtthhopeiivghhrgesuggvsghirghnrdhorh hgpdhrtghpthhtohepshgrmhesghgvnhhtohhordhorhhgpdhrtghpthhtohepmhgrthht shhtkeeksehgmhgrihhlrdgtohhmpdhrtghpthhtohepkhgvvghssehkvghrnhgvlhdroh hrghdprhgtphhtthhopehprghulhhmtghksehkvghrnhgvlhdrohhrghdprhgtphhtthho pehlihhnuhigqdhmmheskhhvrggtkhdrohhrghdprhgtphhtthhopehrihgthhgrrhgurd hhvghnuggvrhhsohhnsehlihhnrghrohdrohhrghdprhgtphhtthhopehgvggvrhhtsehl ihhnuhigqdhmieekkhdrohhrghdprhgtphhtthhopehlohhonhhgrghrtghhsehlihhsth hsrdhlihhnuhigrdguvghv X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 33BF12220072; Thu, 9 Jan 2025 11:52:39 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 Date: Thu, 09 Jan 2025 17:52:18 +0100 From: "Arnd Bergmann" To: "Eric W. Biederman" , "John Paul Adrian Glaubitz" Cc: "Richard Henderson" , "Matt Turner" , "Kees Cook" , "Paul E. McKenney" , linux-alpha@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Michael Cree" , "Sam James" , "Maciej W. Rozycki" , "Geert Uytterhoeven" , "Michael Karcher" , "Chris Hofstaedtler" , util-linux@vger.kernel.org, linux-mips@vger.kernel.org, loongarch@lists.linux.dev Message-Id: <9b1749f0-e936-4bf5-90d6-8cf15e4f0ed9@app.fastmail.com> In-Reply-To: <87ed1cufj1.fsf@email.froward.int.ebiederm.org> References: <20250103140148.370368-1-glaubitz@physik.fu-berlin.de> <24f03227-1b55-4e50-b6e9-7ac74fda2602@app.fastmail.com> <678ee681-12c3-4e79-a04b-495daf343846@app.fastmail.com> <82d33a2d-dffe-4268-a175-4536b3f9c07f@app.fastmail.com> <87ed1cufj1.fsf@email.froward.int.ebiederm.org> Subject: Re: [PATCH] alpha: Fix personality flag propagation across an exec Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: CFB001A000A X-Stat-Signature: fnr64nb378ghmjf83bzt866n1b8tiskj X-Rspam-User: X-HE-Tag: 1736441562-347989 X-HE-Meta: U2FsdGVkX1/IeFuw67UlwwwwAU2i3lmObcwZngOOyBV4jXvc4G6kFM8ovvrNe+ZX/+Cl0WMr8TecyHNz3vsHsTF7YUqIjJBbj36MBaPNyPYcP1khS30Dq+a9YfdfAXOW5zVkPwUDYegeUbETf5s3HUUs++3fOeTPrwGM37HLfXsnUuJTjbu6hx6Iv94jwC9BtB9fYckd1qGbEtRJ/JyeDSgy3zE4wZS0yCWwc8xY4udkYFqIL7MD455FuFyanNoUGgVUjlcHAIG5BDFXjskWZObIV9a02uFdtN11KSSvZ7OEDVUITGdTZrdcbY3j4xhFx3wj41nyZBo/u31OrcDXJroiKNOC+SjBBHLlPyNFpQxw00muiI6Fx85Vu3CQ1QgWIDAu3PDtfcL7v/fMZqydnd+Dr6DZsTF+PfEUwatBNu6GyEk83DroiNpq53+JuX9wpPuL2ztxDokyHpSFsiUeD0D/Q/vC2kMw3IFNAYTHAKgvCOyubdf/wVXKe6dy5b34zXWk7XKde67I3dtT4P/diYRMRhKyuVW5HcdZC4h2JpArAUo3W/8PoUEMH2PavhizJWaWvH86/0Lh8q2Bg2wFEcHK1kVDSb4pU1+/SXUmRo2UdpbCaDy/z6CnQEo9af+icgfMxtOBriU02GHpOZd2NjgvEFIHxomWQJGf5l3jwFXnPh/2DMxv8wEUcFGgjVvQsIklaq9MyZ4ow+5SLu8Q/hu0fulfv6NFIxPuPydUgBO3gsvQobPxOlS/aFh/hUfSkYSwuXITQeyySEJVGs8fUCVZKqRL6TJplLV8Dlf32gSnahsqkwYwDNQ21Vcjd4lsw/lrcDOJU0lG1YuSYQcaT+M6M7MLHobwCTxC7i0kIQ/dHU0bdVp67CCLFOcQGvEpi5C793XN6pV1Q9OFCzrPkbR26LFyEyeBh+ynrzLTnDc69oapsfBPP94rq74BV2R34aIaN3yNkk7XaHL/FzQ mFbVWzeX Hn8CL4f9lMJLLJSvV3mbwdFMSmPZcTq4CHV2MaFDb3iWF1tiYwr/iDZ3gRBE1AiMeVwqw/RfUhU9FlW9jwC/DH9b7IrKME3binQDJhL2sRlvJPqYXK1bLkXYNKz92iwMiMSvr9OypK9sj1JYWpMor5uV4bbKO4bjBUR9sa6OlJ8VtfJ7FSv1bnWjQsY/XWjbQyXaCT7z3ngWIZ2Wao02aJcN1SU1AA0qbx8q7 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: List-Subscribe: List-Unsubscribe: On Thu, Jan 9, 2025, at 17:18, Eric W. Biederman wrote: > John Paul Adrian Glaubitz writes: >> On Thu, 2025-01-09 at 09:56 +0100, Arnd Bergmann wrote: >>> On Thu, Jan 9, 2025, at 09:46, John Paul Adrian Glaubitz wrote: >>> > On Thu, 2025-01-09 at 09:43 +0100, Arnd Bergmann wrote: >>> > > On Thu, Jan 9, 2025, at 09:01, Arnd Bergmann wrote: >>> > > > This looks wrong to me: since ADDR_LIMIT_32BIT is not part of >>> > > > PER_MASK, executing a regular binary from a taso binary no longer >>> > > > reverts back to the entire 64-bit address space. >>> > > > >>> > > > It seems that the behavior on most other architectures changed in 2012 >>> > > > commit 16f3e95b3209 ("cross-arch: don't corrupt personality flags upon >>> > > > exec()"). >>> > > > >>> > >>> > So, if I understand this correctly, we should just use PER_MASK on alpha >>> > for 64-bit executables and allow the bits to be cleared for 32-bit binaries? >>> >>> I think ideally the EF_ALPHA_32BIT handling should use TIF_32BIT >>> as we do on other architectures, at that point the custom SET_PERSONALITY() >>> can be removed in favor of the asm-generic version. >> >> I have thought about that as well but I wasn't sure whether the extra >> mangling on alpha was necessary. >> >>> Alternatively this could do something like the arm32 version (note >>> that on arm, PER_LINUX_32BIT/ADDR_LIMIT_32BIT means "allow using >>> the entire 32-bit address space rather than limiting to 26 bits for >>> compatibility", while on alpha it means "use only 31 instead of >>> 42 bits for addressing", but the logic can be the same): >>> >>> unsigned int personality = current->personality & ~PER_MASK; >>> /* >>> * APCS-26 is only valid for OABI executables >>> */ >>> if ((eflags & EF_ARM_EABI_MASK) == EF_ARM_EABI_UNKNOWN && >>> (eflags & EF_ARM_APCS_26)) >>> personality &= ~ADDR_LIMIT_32BIT; >>> else >>> personality |= ADDR_LIMIT_32BIT; >>> set_personality(personality); >> >> So, this would be the 100% correct for alpha then which would not loose >> any functionality even for 32-bit binaries? > > I don't think it is correct to think about 32-bit binaries on alpha. > > Alpha never had a 32bit instruction set. But at some point it looks > like binaries that could not handle more than 31 bits of address > space got ported and someone implemented a work-around. I guess this > is the --taso option that Arnd mentioned. There was a well-documented use case for taso with emulation for OSF/1 a.out binaries, in particular Netscape used 32-bit pointers. However, the a.out support got removed a while back, and I have not figured out why it was ever added for ELF. Maybe it was just easy to duplicate this from the a.out loader? Obviously some 30 years ago it was common that software was broken on 64-bit because of invalid integer-pointer casting, but these days, it's much more common to be broken on 32-bit instead. > I think the alpha version would look like: > > #define SET_PERSONALITY(ex) \ > do { \ > unsigned long personality = current->personality & ~PER_MASK; \ > if ((EX).e_flags & EF_ALPHA_32BIT) \ > personality |= ADDR_LIMIT_32BIT; \ > else \ > personality &= ~ADDR_LIMIT_32BIT \ > set_personality(personality); \ > while (0) Yes, that was what I was suggesting. > I do see code under arch/alpha/ testing ADDR_LIMIT_32BIT when > setting STACK_TOP, TASK_UNMAPPED_BASE, and arch_get_unmapped_area. > So I think the code still works. MIPS introduced the SET_PERSONALITY2() macro specifically to allow the TIF flags to be set early enough to apply to the stack allocation, so I suspect it only works partially. Arnd