Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp68617rdb; Sun, 28 Jan 2024 14:15:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IG0lpPxTLsqoz/wwu7Zi5nzQtHLYUGVQO5D/KUZ4xVqTGAWxpDQrWQux+g+/333OOSh5Dqv X-Received: by 2002:a17:902:ed97:b0:1d8:d02f:a05a with SMTP id e23-20020a170902ed9700b001d8d02fa05amr1510181plj.34.1706480153447; Sun, 28 Jan 2024 14:15:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706480153; cv=pass; d=google.com; s=arc-20160816; b=ZQ8UAKZDpamtyIjxH/w+iVzMFUu2VuBHyYnPpOHTgiHIrIFnCJRfsQu7L3ISb0Yacv YpjWeAxyC5qWsAWSSQH6bqVkFG+m6ed4XAvv3Rl9I5Hjgosvu0ZQjKWMXHSy+ChDooQ9 5lhzY0M92rZANDNpBlxPXA32RoSUQk+LlN8YIxDv8DonBgp/uZge1ODclv/mlDBDTvXp zClaIeb53rMTLQlsg2rQVQtpuhXaw6bugHTrHS+2nzLJya8tSWzDcWiJWxkKFAmoSEIj wbQmDh/Nn7bxJx8JNKBd78tqw7epQ3E58z3Cqd5HjAyPauQK/kjeVxGcqFSaXgLipiJJ uMUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=SStFBTJSTCY5dWl9OG1r3QddVu+lh2KmbcI7zPlBS1E=; fh=Zddy29Ne65DJm8KnMVLNXlZLOXVVT9ue2T1KGIqsodc=; b=VILgO93fvLFA36HHzY6sThK331wiRK9nq30FHw1hXG0ve7TIFv/IKhmcyRS3G+c68W oy3pbszS7A8uEPmZzb9OxzysTyBorlftZFAMPlGUkoY3aAh3vc5Oi8WJd7znO4x44pEp /E0g7gq/eG94wfCQrSSuY4Ib/MvpZWhQ7jGFSsrx201F2Z4Fgz8v7JoADWLsA5Lr34dF kgkM70o038O76q1qnLVpSCPO7xZJ21FC/h1cTXFSYtNXz42lEQ626mTtcHyC4i+yVj+F 7FZsdd263jxzePudJxxcHuT41dWkEdE3+EKk34XHUQMDwE83S7d5d4UyD4As/GXM7EhH vnZQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=alpha.franken.de); spf=pass (google.com: domain of linux-kernel+bounces-41981-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41981-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e17-20020a656791000000b005d5d32bf0cdsi4643976pgr.256.2024.01.28.14.15.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 14:15:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41981-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=alpha.franken.de); spf=pass (google.com: domain of linux-kernel+bounces-41981-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41981-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 17C3D2839ED for ; Sun, 28 Jan 2024 22:15:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 50DB63C494; Sun, 28 Jan 2024 22:15:44 +0000 (UTC) Received: from elvis.franken.de (elvis.franken.de [193.175.24.41]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 042E23C46B; Sun, 28 Jan 2024 22:15:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.175.24.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706480143; cv=none; b=L1vdBk2IRMrW/ARQeFveLzCwMjYbn8JrhDwfVhcMG80f8vi4C+OFfpJO9+PY+T07YYNz9JuQ86FmDRxhIX1nuhMd0sGxcJK0lJbo4Su/mlW3zoigBOHoANVTeh6N3t/BkwaXcxRtqFouLGYwHIC2JzTnvMsdLo7EvvtYeGT4Vnw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706480143; c=relaxed/simple; bh=vNYgDf0RboUzfGtK3sr9l72mJp9VU/gn//gCBuw27QM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AFBm4xDMhc7X6dBvYpJoj00q2RCq2zSJUKgJ7R7b1rsztNOIXCgP0uE0c2g9TlA3Dwk6qPgyMlM2X2McLUEvTaE9/m+3NXJA0oaW9qKjeXL09bhrbYB5IR/lCyXA243xXqfjhAbXIS+iS1H38tVimWHaTqa03Wi3jLEMKwvMmF8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=alpha.franken.de; spf=pass smtp.mailfrom=alpha.franken.de; arc=none smtp.client-ip=193.175.24.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=alpha.franken.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alpha.franken.de Received: from uucp by elvis.franken.de with local-rmail (Exim 3.36 #1) id 1rUDR3-0005sj-00; Sun, 28 Jan 2024 23:15:29 +0100 Received: by alpha.franken.de (Postfix, from userid 1000) id 8EF83C0489; Sun, 28 Jan 2024 22:54:08 +0100 (CET) Date: Sun, 28 Jan 2024 22:54:08 +0100 From: Thomas Bogendoerfer To: Xi Ruoyao Cc: Jiaxun Yang , linux-mips@vger.kernel.org, Ralf Baechle , "Maciej W. Rozycki" , YunQiang Su , Huacai Chen , WANG Xuerui , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2] mips: Call lose_fpu(0) before initializing fcr31 in mips_set_personality_nan Message-ID: References: <20240126210557.12442-1-xry111@xry111.site> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240126210557.12442-1-xry111@xry111.site> On Sat, Jan 27, 2024 at 05:05:57AM +0800, Xi Ruoyao wrote: > If we still own the FPU after initializing fcr31, when we are preempted > the dirty value in the FPU will be read out and stored into fcr31, > clobbering our setting. This can cause an improper floating-point > environment after execve(). For example: > > zsh% cat measure.c > #include > int main() { return fetestexcept(FE_INEXACT); } > zsh% cc measure.c -o measure -lm > zsh% echo $((1.0/3)) # raising FE_INEXACT > 0.33333333333333331 > zsh% while ./measure; do ; done > (stopped in seconds) > > Call lose_fpu(0) before setting fcr31 to prevent this. > > Closes: https://lore.kernel.org/linux-mips/7a6aa1bbdbbe2e63ae96ff163fab0349f58f1b9e.camel@xry111.site/ > Fixes: 9b26616c8d9d ("MIPS: Respect the ISA level in FCSR handling") > Cc: stable@vger.kernel.org > Signed-off-by: Xi Ruoyao > --- > > v1 -> v2: Fix stable list address in Cc line. > > arch/mips/kernel/elf.c | 6 ++++++ > 1 file changed, 6 insertions(+) applied to mips-fixes. Thomas. -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]