Re: 2.6.10-rc3, i386: fpu handling on sigreturn

From: Andi Kleen
Date: Wed Dec 22 2004 - 18:26:56 EST


Bodo Stroesser <bstroesser@xxxxxxxxxxxxxxxxxxx> writes:
>
> Now, the interrupted processes fpu no longer is cleared!

I agree it's a bug, although it's probably pretty obscure so people
didn't notice it. The right fix would be to just clear_fpu again
in this case. The problem has been in Linux forever.

Here's an untested patch for i386 and x86-64.

-Andi

diff -u linux-2.6.10rc2-time/arch/i386/kernel/signal.c-o linux-2.6.10rc2-time/arch/i386/kernel/signal.c
--- linux-2.6.10rc2-time/arch/i386/kernel/signal.c-o 2004-11-15 12:34:25.000000000 +0100
+++ linux-2.6.10rc2-time/arch/i386/kernel/signal.c 2004-12-23 00:07:18.000000000 +0100
@@ -190,7 +190,8 @@
if (verify_area(VERIFY_READ, buf, sizeof(*buf)))
goto badframe;
err |= restore_i387(buf);
- }
+ } else if (current->used_math)
+ clear_fpu(current);
}

err |= __get_user(*peax, &sc->eax);
diff -u linux-2.6.10rc2-time/arch/x86_64/kernel/signal.c-o linux-2.6.10rc2-time/arch/x86_64/kernel/signal.c
--- linux-2.6.10rc2-time/arch/x86_64/kernel/signal.c-o 2004-10-19 01:55:08.000000000 +0200
+++ linux-2.6.10rc2-time/arch/x86_64/kernel/signal.c 2004-12-23 00:07:19.000000000 +0100
@@ -125,7 +125,8 @@
if (verify_area(VERIFY_READ, buf, sizeof(*buf)))
goto badframe;
err |= restore_i387(buf);
- }
+ } else if (current->used_math)
+ clear_fpu(current);
}

err |= __get_user(*prax, &sc->rax);
diff -u linux-2.6.10rc2-time/arch/x86_64/ia32/ia32_signal.c-o linux-2.6.10rc2-time/arch/x86_64/ia32/ia32_signal.c
--- linux-2.6.10rc2-time/arch/x86_64/ia32/ia32_signal.c-o 2004-10-19 01:55:08.000000000 +0200
+++ linux-2.6.10rc2-time/arch/x86_64/ia32/ia32_signal.c 2004-12-23 00:07:17.000000000 +0100
@@ -261,7 +261,8 @@
if (verify_area(VERIFY_READ, buf, sizeof(*buf)))
goto badframe;
err |= restore_i387_ia32(current, buf, 0);
- }
+ } else if (current->used_math)
+ clear_fpu(current);
}

{

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/