Clear TLS on execve
PATCH 1/1 Clear TLS on execve
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.
arch/i386/kernel/process.c +1 -0
@@ -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.. */
Quoted 4 lines · Luca Barbieri
This trivial patch causes the TLS to be cleared on execve (code is in
flush_thread). This is necessary to avoid ESRCH errors whenset_thread_areais asked to choose a free TLS entry after several nested execve's.
Ouch!
Quoted 3 lines
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