From: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
To: Xi Ruoyao <xry111@xry111.site>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>,
linux-mips@vger.kernel.org, Ralf Baechle <ralf@linux-mips.org>,
"Maciej W. Rozycki" <macro@orcam.me.uk>,
YunQiang Su <wzssyqa@gmail.com>,
Huacai Chen <chenhuacai@kernel.org>,
WANG Xuerui <kernel@xen0n.name>,
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
Date: Sun, 28 Jan 2024 22:54:08 +0100 [thread overview]
Message-ID: <ZbbNAESbgzwJN5qc@alpha.franken.de> (raw)
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 <fenv.h>
> 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 <xry111@xry111.site>
> ---
>
> 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 ]
prev parent reply other threads:[~2024-01-28 22:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-26 21:05 Xi Ruoyao
2024-01-28 21:54 ` Thomas Bogendoerfer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZbbNAESbgzwJN5qc@alpha.franken.de \
--to=tsbogend@alpha.franken.de \
--cc=chenhuacai@kernel.org \
--cc=jiaxun.yang@flygoat.com \
--cc=kernel@xen0n.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=macro@orcam.me.uk \
--cc=ralf@linux-mips.org \
--cc=stable@vger.kernel.org \
--cc=wzssyqa@gmail.com \
--cc=xry111@xry111.site \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®