r2503 - in glibc-package/trunk/debian: . patches/hurd-i386
Author: sthibaul-guest
Date: 2007-08-10 07:39:56 +0000 (Fri, 10 Aug 2007)
New Revision: 2503
Modified:
glibc-package/trunk/debian/changelog
glibc-package/trunk/debian/patches/hurd-i386/local-tls-support.diff
Log:
* hurd-i386/local-tls-support.diff: update to fix TLS leak in /hurd/exec
server.
Modified: glibc-package/trunk/debian/changelog
===================================================================
--- glibc-package/trunk/debian/changelog 2007-08-09 22:14:08 UTC (rev 2502)
+++ glibc-package/trunk/debian/changelog 2007-08-10 07:39:56 UTC (rev 2503)
@@ -7,6 +7,8 @@
hurd-i386/submitted-sigsuspend-nocancel.diff into
hurd-i386/cvs-sigsuspend-nocancel.diff as the patches have been accepted
upstream.
+ * hurd-i386/local-tls-support.diff: update to fix TLS leak in /hurd/exec
+ server.
-- Aurelien Jarno <aurel32@debian.org> Wed, 01 Aug 2007 16:40:01 +0200
Modified: glibc-package/trunk/debian/patches/hurd-i386/local-tls-support.diff
===================================================================
--- glibc-package/trunk/debian/patches/hurd-i386/local-tls-support.diff 2007-08-09 22:14:08 UTC (rev 2502)
+++ glibc-package/trunk/debian/patches/hurd-i386/local-tls-support.diff 2007-08-10 07:39:56 UTC (rev 2503)
@@ -25,6 +25,39 @@
MACHINE_THREAD_STATE_SET_PC (&state, faulted);
MACHINE_THREAD_STATE_SET_SP (&state, faultstack, sizeof faultstack);
+diff -u -p -r1.159 hurdsig.c
+--- hurd/hurdsig.c 21 Dec 2005 22:16:20 -0000 1.159
++++ hurd/hurdsig.c 9 Aug 2007 19:17:33 -0000
+@@ -1260,6 +1260,8 @@ _hurdsig_init (const int *intarray, size
+ (vm_address_t *) &__hurd_sigthread_stack_base,
+ &stacksize);
+ assert_perror (err);
++ err = __mach_setup_tls (_hurd_msgport_thread);
++ assert_perror (err);
+
+ __hurd_sigthread_stack_end = __hurd_sigthread_stack_base + stacksize;
+ __hurd_sigthread_variables =
+@@ -1268,8 +1270,6 @@ _hurdsig_init (const int *intarray, size
+ __libc_fatal ("hurd: Can't allocate threadvars for signal thread\n");
+ memset (__hurd_sigthread_variables, 0,
+ __hurd_threadvar_max * sizeof (unsigned long int));
+- __hurd_sigthread_variables[_HURD_THREADVAR_LOCALE]
+- = (unsigned long int) &_nl_global_locale;
+
+ /* Reinitialize the MiG support routines so they will use a per-thread
+ variable for the cached reply port. */
+diff -u -p -r1.13 mach.h
+--- mach/mach.h 30 Aug 2002 01:30:53 -0000 1.13
++++ mach/mach.h 9 Aug 2007 19:17:33 -0000
+@@ -101,5 +101,8 @@ kern_return_t mach_setup_thread (task_t
+ vm_address_t *stack_base,
+ vm_size_t *stack_size);
+
++/* Give THREAD a TLS area. */
++kern_return_t __mach_setup_tls (thread_t thread);
++kern_return_t mach_setup_tls (thread_t thread);
+
+ #endif /* mach.h */
--- mach/setup-thread.c.orig
+++ mach/setup-thread.c
@@ -20,6 +20,7 @@
@@ -35,31 +68,43 @@
#include "sysdep.h" /* Defines stack direction. */
#define STACK_SIZE (16 * 1024 * 1024) /* 16MB, arbitrary. */
-@@ -73,8 +74,23 @@
+@@ -73,8 +74,35 @@ __mach_setup_thread (task_t task, thread
if (error = __vm_protect (task, stack, __vm_page_size, 0, VM_PROT_NONE))
return error;
- return __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR,
-+ if (error = __thread_set_state (thread, MACHINE_NEW_THREAD_STATE_FLAVOR,
-+ (natural_t *) &ts, tssize))
-+ return error;
++ return __thread_set_state (thread, MACHINE_NEW_THREAD_STATE_FLAVOR,
+ (natural_t *) &ts, tssize);
+ }
+
+ weak_alias (__mach_setup_thread, mach_setup_thread)
+
-+ /* now we have a clean state, setup TLS */
++/* Give THREAD a TLS area. */
++kern_return_t
++__mach_setup_tls (thread_t thread)
++{
++ kern_return_t error;
++ struct machine_thread_state ts;
++ mach_msg_type_number_t tssize = MACHINE_THREAD_STATE_COUNT;
++ tcbhead_t *tcb;
++
+ if (error = __thread_get_state (thread, MACHINE_THREAD_STATE_FLAVOR,
+ (natural_t *) &ts, &tssize))
+ return error;
+ assert (tssize == MACHINE_THREAD_STATE_COUNT);
-+ tcbhead_t *tcb;
++
+ tcb = _dl_allocate_tls(NULL);
+ if (!tcb)
+ return KERN_RESOURCE_SHORTAGE;
++
+ _hurd_tls_new(thread, &ts, tcb);
++
+ error = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR,
- (natural_t *) &ts, tssize);
++ (natural_t *) &ts, tssize);
+ return error;
- }
-
- weak_alias (__mach_setup_thread, mach_setup_thread)
++}
++
++weak_alias (__mach_setup_tls, mach_setup_tls)
--- sysdeps/generic/thread_state.h.orig
+++ sysdeps/generic/thread_state.h
@@ -23,6 +23,7 @@
@@ -115,6 +160,70 @@
LOSE;
if (err = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR,
+--- sysdeps/mach/hurd/profil.c 16 Oct 2005 10:32:15 -0000 1.11
++++ sysdeps/mach/hurd/profil.c 9 Aug 2007 19:17:34 -0000
+@@ -69,6 +69,8 @@ update_waiter (u_short *sample_buffer, s
+ if (! err)
+ err = __mach_setup_thread (__mach_task_self (), profile_thread,
+ &profile_waiter, NULL, NULL);
++ if (! err)
++ err = __mach_setup_tls(profile_thread);
+ }
+ else
+ err = 0;
+--- sysdeps/mach/hurd/setitimer.c 16 Oct 2005 10:32:15 -0000 1.23
++++ sysdeps/mach/hurd/setitimer.c 9 Aug 2007 21:03:24 -0000
+@@ -223,11 +223,12 @@ setitimer_locked (const struct itimerval
+ return __hurd_fail (err);
+ _hurd_itimer_thread_stack_base = 0; /* Anywhere. */
+ _hurd_itimer_thread_stack_size = __vm_page_size; /* Small stack. */
+- if (err = __mach_setup_thread (__mach_task_self (),
++ if ((err = __mach_setup_thread (__mach_task_self (),
+ _hurd_itimer_thread,
+ &timer_thread,
+ &_hurd_itimer_thread_stack_base,
+ &_hurd_itimer_thread_stack_size))
++ || (err = __mach_setup_tls(_hurd_itimer_thread)))
+ {
+ __thread_terminate (_hurd_itimer_thread);
+ _hurd_itimer_thread = MACH_PORT_NULL;
+--- sysdeps/mach/hurd/bits/libc-tsd.h
++++ /dev/null
+@@ -1,34 +0,0 @@
+-/* libc-internal interface for thread-specific data. Hurd version.
+- Copyright (C) 1998,2002 Free Software Foundation, Inc.
+- This file is part of the GNU C Library.
+-
+- The GNU C Library is free software; you can redistribute it and/or
+- modify it under the terms of the GNU Lesser General Public
+- License as published by the Free Software Foundation; either
+- version 2.1 of the License, or (at your option) any later version.
+-
+- The GNU C Library is distributed in the hope that it will be useful,
+- but WITHOUT ANY WARRANTY; without even the implied warranty of
+- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+- Lesser General Public License for more details.
+-
+- You should have received a copy of the GNU Lesser General Public
+- License along with the GNU C Library; if not, write to the Free
+- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+- 02111-1307 USA. */
+-
+-#ifndef _BITS_LIBC_TSD_H
+-#define _BITS_LIBC_TSD_H 1
+-
+-#include <hurd/threadvar.h>
+-
+-#define __libc_tsd_define(CLASS, KEY) /* nothing, always have threadvars */
+-
+-#define __libc_tsd_address(KEY) \
+- ((void **) __hurd_threadvar_location (_HURD_THREADVAR_##KEY))
+-
+-#define __libc_tsd_get(KEY) (*__libc_tsd_address (KEY))
+-#define __libc_tsd_set(KEY, VALUE) (*__libc_tsd_address (KEY) = (VALUE))
+-
+-
+-#endif /* bits/libc-tsd.h */
--- sysdeps/mach/hurd/i386/init-first.c.orig
+++ sysdeps/mach/hurd/i386/init-first.c
@@ -104,10 +104,6 @@
@@ -156,7 +265,7 @@
_hurd_init_dtable = d->dtable;
_hurd_init_dtablesize = d->dtablesize;
-@@ -172,6 +150,10 @@
+@@ -172,13 +150,16 @@ init (int *data)
char **envp = &argv[argc + 1];
struct hurd_startup_data *d;
unsigned long int threadvars[_HURD_THREADVAR_MAX];
@@ -167,7 +276,14 @@
/* Provide temporary storage for thread-specific variables on the
startup stack so the cthreads initialization code can use them
-@@ -192,6 +174,39 @@
+ for malloc et al, or so we can use malloc below for the real
+ threadvars array. */
+ memset (threadvars, 0, sizeof threadvars);
+- threadvars[_HURD_THREADVAR_LOCALE] = (unsigned long int) &_nl_global_locale;
+ __hurd_threadvar_stack_offset = (unsigned long int) threadvars;
+
+ /* Since the cthreads initialization code uses malloc, and the
+@@ -192,6 +173,39 @@ init (int *data)
++envp;
d = (void *) ++envp;
@@ -325,40 +441,3 @@
#define MACHINE_THREAD_STATE_FLAVOR PPC_THREAD_STATE
#define MACHINE_THREAD_STATE_COUNT PPC_THREAD_STATE_COUNT
---- sysdeps/mach/hurd/bits/libc-tsd.h
-+++ /dev/null
-@@ -1,34 +0,0 @@
--/* libc-internal interface for thread-specific data. Hurd version.
-- Copyright (C) 1998,2002 Free Software Foundation, Inc.
-- This file is part of the GNU C Library.
--
-- The GNU C Library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
--
-- The GNU C Library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with the GNU C Library; if not, write to the Free
-- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-- 02111-1307 USA. */
--
--#ifndef _BITS_LIBC_TSD_H
--#define _BITS_LIBC_TSD_H 1
--
--#include <hurd/threadvar.h>
--
--#define __libc_tsd_define(CLASS, KEY) /* nothing, always have threadvars */
--
--#define __libc_tsd_address(KEY) \
-- ((void **) __hurd_threadvar_location (_HURD_THREADVAR_##KEY))
--
--#define __libc_tsd_get(KEY) (*__libc_tsd_address (KEY))
--#define __libc_tsd_set(KEY, VALUE) (*__libc_tsd_address (KEY) = (VALUE))
--
--
--#endif /* bits/libc-tsd.h */
Reply to: