From: Steve Muckle <smuckle.linux@gmail.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] syscalls/kcmp03: work around bug in C library
Date: Tue, 5 Sep 2017 13:40:29 -0700 [thread overview]
Message-ID: <20170905204029.66280-1-smuckle.linux@gmail.com> (raw)
Some versions of glibc and bionic report the same PID for parent and
child when clone() is called with CLONE_VM but not CLONE_THREAD. This
causes an issue in the cleanup path which is supposed to execute in the
parent. If kcmp() support is not present, the child aborts and then
erroneously runs the cleanup handler, freeing its own stack.
Avoid this by statically allocating the stack.
Signed-off-by: Steve Muckle <smuckle.linux@gmail.com>
---
testcases/kernel/syscalls/kcmp/kcmp03.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/testcases/kernel/syscalls/kcmp/kcmp03.c b/testcases/kernel/syscalls/kcmp/kcmp03.c
index b6ca40cff..465cb1e8b 100644
--- a/testcases/kernel/syscalls/kcmp/kcmp03.c
+++ b/testcases/kernel/syscalls/kcmp/kcmp03.c
@@ -40,7 +40,13 @@
static int pid1;
static int pid2;
-static void *stack;
+
+/*
+ * The cleanup handler may be run in the child due to a bug in some versions of
+ * glibc and bionic when clone() is called with CLONE_VM but not CLONE_THREAD.
+ * Use static allocation of stack to avoid this.
+ */
+static char stack[STACK_SIZE];
static struct tcase {
int clone_type;
@@ -52,16 +58,6 @@ static struct tcase {
{CLONE_SYSVSEM, KCMP_SYSVSEM}
};
-static void setup(void)
-{
- stack = SAFE_MALLOC(STACK_SIZE);
-}
-
-static void cleanup(void)
-{
- free(stack);
-}
-
static int do_child(void *arg)
{
pid2 = getpid();
@@ -96,8 +92,6 @@ static void verify_kcmp(unsigned int n)
static struct tst_test test = {
.tcnt = ARRAY_SIZE(tcases),
- .setup = setup,
- .cleanup = cleanup,
.forks_child = 1,
.test = verify_kcmp,
.min_kver = "3.5.0"
--
2.14.1.581.gf28d330327-goog
next reply other threads:[~2017-09-05 20:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-05 20:40 Steve Muckle [this message]
2017-09-06 10:09 ` [LTP] [PATCH] syscalls/kcmp03: work around bug in C library Cyril Hrubis
2017-09-07 17:42 ` Steve Muckle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170905204029.66280-1-smuckle.linux@gmail.com \
--to=smuckle.linux@gmail.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox