From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12455 Path: news.gmane.org!.POSTED!not-for-mail From: William Pitcock Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH v2] track pthread stack guard sizes Date: Fri, 2 Feb 2018 20:08:55 +0000 Message-ID: <20180202200855.1514-1-nenolod@dereferenced.org> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1517602091 1084 195.159.176.226 (2 Feb 2018 20:08:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 2 Feb 2018 20:08:11 +0000 (UTC) Cc: William Pitcock To: musl@lists.openwall.com Original-X-From: musl-return-12471-gllmg-musl=m.gmane.org@lists.openwall.com Fri Feb 02 21:08:07 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 1ehhcT-0006Yj-PD for gllmg-musl@m.gmane.org; Fri, 02 Feb 2018 21:07:33 +0100 Original-Received: (qmail 13564 invoked by uid 550); 2 Feb 2018 20:09:29 -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 13519 invoked from network); 2 Feb 2018 20:09:28 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dereferenced-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=KSg9sAArWdEK59tzvvjDOcM0eQOyNjzRkFwEPlzu3nc=; b=AS4QTuTAjEgVmZKBrErOwB/kFZZLV/ntlbA6anYsshgB8icZB/B9mKctZfwgN5QMHr qgg4FMZNtSJxG7QGLHHSRYedGlnik8Rn2zLJon/dZEcgAXnzCoFbJbd2uli8IsC8rX3T Vu3AnUWIrXS3/TS9pBy7Z6/s8R+15azPrZWqGDfdCWp98R2EBdYd2awwvg85jyT5bkFS sZgz7rRQqmM9uUQNstAvSPGhfj6rY11ZUJTPhdPEit2h3DrmWkpeQpAnnCdMXJj8VcNc T4FJ8psyw4uFhNscv5tXyx/k/VucgtKEkaYGOaXA0fkbVV0XweRmAvq5kawQ2rmxWIDY DRXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=KSg9sAArWdEK59tzvvjDOcM0eQOyNjzRkFwEPlzu3nc=; b=XuYqRT0lQHXqlf1lNeN1UhkaFQI1VYjS1uM1vdezYEM5juo74Y2fN8pfzNsEWWcqOH qDuvG8kNzwCPaWHy0yrbjFecjCyuHai2Wrxr1b4MoYQf4Q5ZTuVw02yFExxn8jnJfADe X9St+2+q9LrFelxEIecAyb3TNrEvBSXlZ17drRnj2reU1steToWlr95/D9C0jxNprNF6 B/G5/nTK12BBv7gh//QnWV0KOXg3NlMh/cf5a/k8IU4kBbGBFyzJUbza4PAJRof4b9oR gn00wWguWCVQy7um8GxVM28KeuftB7p7oLPzT7zaLpGLdL9noz5lLppIwLFl15I7pdcZ Uahw== X-Gm-Message-State: AKwxytepNcV3PNZQodq5OcJHjndVq0atEHmsHtNMoBxOMsNQ5B8bfEY6 86jWg7kDo6duneEOI3LvZrJu9a09 X-Google-Smtp-Source: AH8x225nl0aciFzkNWXAOxaPwRipXWSkSa4PzPQCVovOBEwPYM9vOngF2eIf+m51Um14Xv2MYBY49g== X-Received: by 10.107.78.5 with SMTP id c5mr46222117iob.120.1517602156851; Fri, 02 Feb 2018 12:09:16 -0800 (PST) X-Mailer: git-send-email 2.16.1 Xref: news.gmane.org gmane.linux.lib.musl.general:12455 Archived-At: some applications (rustc) are dependent on pthread_getattr_np() providing the guard size. --- src/internal/pthread_impl.h | 1 + src/thread/pthread_create.c | 3 ++- src/thread/pthread_getattr_np.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h index f0b2c20c..4a0db987 100644 --- a/src/internal/pthread_impl.h +++ b/src/internal/pthread_impl.h @@ -46,6 +46,7 @@ struct pthread { char *dlerror_buf; int dlerror_flag; void *stdio_locks; + size_t guard_size; uintptr_t canary_at_end; void **dtv_copy; }; diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c index 34cd9936..439ee363 100644 --- a/src/thread/pthread_create.c +++ b/src/thread/pthread_create.c @@ -232,8 +232,8 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att memset(stack, 0, need); } else { size = ROUND(need); - guard = 0; } + guard = 0; } else { guard = ROUND(attr._a_guardsize); size = guard + ROUND(attr._a_stacksize @@ -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.16.1