From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12350 Path: news.gmane.org!.POSTED!not-for-mail From: William Pitcock Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] track pthread stack guard sizes Date: Tue, 9 Jan 2018 16:24:06 -0600 Message-ID: References: <20180106044443.14260-1-nenolod@dereferenced.org> <20180109172204.GY1627@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1515536545 1309 195.159.176.226 (9 Jan 2018 22:22:25 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 9 Jan 2018 22:22:25 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-12366-gllmg-musl=m.gmane.org@lists.openwall.com Tue Jan 09 23:22:21 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1eZ2Hj-0008VD-Kd for gllmg-musl@m.gmane.org; Tue, 09 Jan 2018 23:22:19 +0100 Original-Received: (qmail 17914 invoked by uid 550); 9 Jan 2018 22:24:19 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 17885 invoked from network); 9 Jan 2018 22:24:18 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dereferenced-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=8BeTViq0W6jTGCnPlIRVlezfTG593Lrm7w/8T4C5QS4=; b=C3pEx1vHWiBWcO7qYWqKvueA5jAjpIuul0xILM46ul3wy8J13cqoiLdMEMeEsOptzo NOvYYGQNlT9JpvJbthXJyBsIXhui3Wkr1uBBw8PO38NUjKmEAKAJZ9C11rEWM8MCoaaV gyW4kZiSfZV+IlRS5hedAavECiKgWMN8xsAt1xg0ni3FJKecddSIL0UwZhCAFVmy+QA/ ffOfkAtkFaKFaFkTvi0EfPBBpL0Dh+Sq8yX4MZ7SWcmhUP94wF01litBcx/yHEU9mauB RqnfTMm1bVUC25rN5EgsPyKW8H2N4NfB3FyA0cdTVL8Qy6FK47/VqvSb70qqIqSvfRWZ ynEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=8BeTViq0W6jTGCnPlIRVlezfTG593Lrm7w/8T4C5QS4=; b=q9G0dGSySorVeQg1PckoIS1oMliD9lE8EGfAq8Ut+kaEs7Wg03xDXY6HNzKLU+y8p+ bh7wq7Ea4DdIfqAx/PIlkXIlTs4+/b+s8QWNO3cCd4ENNzzozU4BnpfTB28B9GvTNPyI r7ZfUBlADAdBgiJ+yb2FCZ0CQCtIM9uRz9oQ0EJKCPq/eA5xsWECBUipCN0BpEAbWkSl Mq1IpRRLybZW86JO6AwU1xxCop7gLYQ7YQpQY9acn77r7nWfzz8u+MsqZfdVS1Vwp8s+ /ThkbN4Bfq6CsDOXKvnIJtV9JgZVLhAvKuisZnGvw6YzpM3QLpyzHZOHqpe/VqygMKpK /SlA== X-Gm-Message-State: AKwxyteAJm2nmLs132nXXa6P425OPjQ7CluppFzsGKMZ7Q9RAg5uNd5j D3Zeip2XFRscpeXOHVXwvEajkXAHxePmE6SPrJN3BQ== X-Google-Smtp-Source: ACJfBov04KJpBqQlAiH1mMhI7ZICRU0ULZlNKVCyf/EDgB3IkCD6alQFW3O4OsZbbv81KqHzVpabG3Qwa9J7E34LoOo= X-Received: by 10.55.56.80 with SMTP id f77mr24972554qka.110.1515536646859; Tue, 09 Jan 2018 14:24:06 -0800 (PST) In-Reply-To: <20180109172204.GY1627@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:12350 Archived-At: Hi, On Tue, Jan 9, 2018 at 11:22 AM, Rich Felker wrote: > On Sat, Jan 06, 2018 at 04:44:43AM +0000, William Pitcock wrote: >> some applications (rustc) are dependent on pthread_getattr_np() providing the guard size. >> --- >> src/internal/pthread_impl.h | 1 + >> src/thread/pthread_create.c | 1 + >> src/thread/pthread_getattr_np.c | 1 + >> 3 files changed, 3 insertions(+) >> >> diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h >> index 56e19348..c2cafeaa 100644 >> --- a/src/internal/pthread_impl.h >> +++ b/src/internal/pthread_impl.h >> @@ -48,6 +48,7 @@ struct pthread { >> void *stdio_locks; >> uintptr_t canary_at_end; >> void **dtv_copy; >> + size_t guard_size; >> }; >> >> struct __timer { >> diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c >> index 6cbf85b3..0faad765 100644 >> --- a/src/thread/pthread_create.c >> +++ b/src/thread/pthread_create.c >> @@ -265,6 +265,7 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att >> new->map_size = size; >> new->stack = stack; >> new->stack_size = stack - stack_limit; >> + new->guard_size = guard; >> new->start = entry; >> new->start_arg = arg; >> new->self = new; >> diff --git a/src/thread/pthread_getattr_np.c b/src/thread/pthread_getattr_np.c >> index ae26a5ab..29a209bd 100644 >> --- a/src/thread/pthread_getattr_np.c >> +++ b/src/thread/pthread_getattr_np.c >> @@ -7,6 +7,7 @@ int pthread_getattr_np(pthread_t t, pthread_attr_t *a) >> { >> *a = (pthread_attr_t){0}; >> a->_a_detach = !!t->detached; >> + a->_a_guardsize = t->guard_size; >> if (t->stack) { >> a->_a_stackaddr = (uintptr_t)t->stack; >> a->_a_stacksize = t->stack_size; >> -- >> 2.15.0 > > I'm pretty sure there's another bug in this patch: the local variable > guard is uninitialized where you use it if the application provided a > stack and TLS was able to be allocated in the app-provided stack. > > The line guard = 0; above should probably just be moved down one line > (and unindented one level). > > Does this sound right? Yes, I would agree that guardsize should be 0 if the app provided a sufficient stack. The rustc error had to do with a libc-provided stack, so was trying to fix it quickly for that case mostly. William