linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Clear TLS on execve
@ 2002-10-31 14:34 Luca Barbieri
  2002-11-01  1:23 ` Jamie Lokier
  0 siblings, 1 reply; 2+ messages in thread
From: Luca Barbieri @ 2002-10-31 14:34 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Linux-Kernel ML, Ingo Molnar

[-- Attachment #1: Type: text/plain, Size: 1008 bytes --]

This trivial patch causes the TLS to be cleared on execve (code is in flush_thread).
This is necessary to avoid ESRCH errors when set_thread_area is asked
to choose a free TLS entry after several nested execve's.

The LDT also has a similar problem, but it is less serious because the
LDT code doesn't scan for free entries. I'll probably send a patch to
fix this too, unless there is something important relying on this behavior.

diff --exclude-from=/home/ldb/src/linux-exclude -urNdp linux-2.5.45/arch/i386/kernel/process.c linux-2.5.45_ldb/arch/i386/kernel/process.c
--- linux-2.5.45/arch/i386/kernel/process.c	2002-10-12 06:21:02.000000000 +0200
+++ linux-2.5.45_ldb/arch/i386/kernel/process.c	2002-10-31 14:23:18.000000000 +0100
@@ -247,6 +247,7 @@ void flush_thread(void)
 	struct task_struct *tsk = current;
 
 	memset(tsk->thread.debugreg, 0, sizeof(unsigned long)*8);
+	memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));	
 	/*
 	 * Forget coprocessor state..
 	 */

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Clear TLS on execve
  2002-10-31 14:34 [PATCH] Clear TLS on execve Luca Barbieri
@ 2002-11-01  1:23 ` Jamie Lokier
  0 siblings, 0 replies; 2+ messages in thread
From: Jamie Lokier @ 2002-11-01  1:23 UTC (permalink / raw)
  To: Linus Torvalds, Linux-Kernel ML, Ingo Molnar

Luca Barbieri wrote:
> This trivial patch causes the TLS to be cleared on execve (code is
> in flush_thread).  This is necessary to avoid ESRCH errors when
> set_thread_area is asked to choose a free TLS entry after several
> nested execve's.

Ouch!

> The LDT also has a similar problem, but it is less serious because the
> LDT code doesn't scan for free entries. I'll probably send a patch to
> fix this too, unless there is something important relying on this behavior.

Ouch again!  Does the LDT really not get released on execve?  I am
using threading code which _does_ scan for free entries in the LDT -
using the lar instruction.  I'd never stumbled across this, though.
I'll be glad of your patch.

-- Jamie

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-11-01  1:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-31 14:34 [PATCH] Clear TLS on execve Luca Barbieri
2002-11-01  1:23 ` Jamie Lokier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).