From: "Serge E. Hallyn" <serue@us.ibm.com>
To: Subrata Modak1 <subrata.modak@in.ibm.com>
Cc: LTP list <ltp-list@lists.sourceforge.net>,
Nathan T Lynch <natlynch@us.ibm.com>
Subject: [LTP] [PATCH 1/1] Containers: Pass a valid stack address to clone
Date: Wed, 2 Sep 2009 09:10:27 -0500 [thread overview]
Message-ID: <20090902141027.GA13905@us.ibm.com> (raw)
Nathan's description:
Off-by-one error: the stack address passed to clone() must be
within the region allocated.
Fortunately most of the containers tests were using the common
helpers.
Also fix the libnetns helper to, like the libclone one, special-case
hppa and pass the bottom of the stack to clone2 for __ia64__ (as per
the libclone example and the clone2 manpage). I don't know and can't
test whether it's right, but have to assume that one of the other was
wrong.
Reported-by: Nathan Lynch <ntl@pobox.com>
Signed-off-by: Serge Hallyn <serge@us.ibm.com>
---
testcases/kernel/containers/libclone/libclone.c | 2 +-
testcases/kernel/containers/libclone/libnetns.c | 8 +++++---
.../containers/sysvipc/check_ipcns_enabled.c | 2 +-
.../containers/utsname/check_utsns_enabled.c | 2 +-
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/testcases/kernel/containers/libclone/libclone.c b/testcases/kernel/containers/libclone/libclone.c
index c97d94b..0fa5827 100644
--- a/testcases/kernel/containers/libclone/libclone.c
+++ b/testcases/kernel/containers/libclone/libclone.c
@@ -35,7 +35,7 @@ int do_clone(unsigned long clone_flags,
#elif defined(__ia64__)
ret = clone2(fn1, stack, stack_size, clone_flags, arg1, NULL, NULL, NULL);
#else
- ret = clone(fn1, stack + stack_size, clone_flags, arg1);
+ ret = clone(fn1, stack + stack_size - 1, clone_flags, arg1);
#endif
if (ret == -1) {
diff --git a/testcases/kernel/containers/libclone/libnetns.c b/testcases/kernel/containers/libclone/libnetns.c
index 821fec1..22461f8 100644
--- a/testcases/kernel/containers/libclone/libnetns.c
+++ b/testcases/kernel/containers/libclone/libnetns.c
@@ -72,7 +72,7 @@ int create_net_namespace(char *p1, char *c1)
perror("failled to malloc memory for stack...");
return -1;
}
- childstack = stack + stack_size;
+ childstack = stack + stack_size - 1;
clone_flags |= CLONE_NEWNS;
/* Enable other namespaces too optionally */
@@ -80,8 +80,10 @@ int create_net_namespace(char *p1, char *c1)
clone_flags |= CLONE_NEWPID;
#endif
-#ifdef __ia64__
- pid = clone2(child_fn, childstack, getpagesize(), clone_flags | SIGCHLD,
+#if defined(__hppa__)
+ ret = clone(child_fn, stack, clone_flags, c1);
+#elif defined(__ia64__)
+ pid = clone2(child_fn, stack, stack_size, clone_flags | SIGCHLD,
(void *)c1, NULL, NULL, NULL);
#else
pid = clone(child_fn, childstack, clone_flags | SIGCHLD, (void *)c1);
diff --git a/testcases/kernel/containers/sysvipc/check_ipcns_enabled.c b/testcases/kernel/containers/sysvipc/check_ipcns_enabled.c
index 3d9b74a..9b2b7ba 100644
--- a/testcases/kernel/containers/sysvipc/check_ipcns_enabled.c
+++ b/testcases/kernel/containers/sysvipc/check_ipcns_enabled.c
@@ -37,7 +37,7 @@ int main()
return 2;
}
- childstack = stack + getpagesize();
+ childstack = stack + getpagesize() - 1;
#ifdef __ia64__
pid = clone2(dummy, childstack, getpagesize(), CLONE_NEWIPC, NULL, NULL, NULL, NULL);
diff --git a/testcases/kernel/containers/utsname/check_utsns_enabled.c b/testcases/kernel/containers/utsname/check_utsns_enabled.c
index 80b9f47..c35b24f 100644
--- a/testcases/kernel/containers/utsname/check_utsns_enabled.c
+++ b/testcases/kernel/containers/utsname/check_utsns_enabled.c
@@ -73,7 +73,7 @@ int main()
return 2;
}
- childstack = stack + getpagesize();
+ childstack = stack + getpagesize() - 1;
#ifdef __ia64__
pid = clone2(dummy, childstack, getpagesize(), CLONE_NEWUTS, NULL, NULL, NULL, NULL);
--
1.6.0.4
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next reply other threads:[~2009-09-02 14:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-02 14:10 Serge E. Hallyn [this message]
2009-09-02 20:13 ` [LTP] [PATCH 1/1] Containers: Pass a valid stack address to clone Mike Frysinger
2009-09-07 11:40 ` Subrata Modak
2009-09-08 4:53 ` Serge E. Hallyn
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=20090902141027.GA13905@us.ibm.com \
--to=serue@us.ibm.com \
--cc=ltp-list@lists.sourceforge.net \
--cc=natlynch@us.ibm.com \
--cc=subrata.modak@in.ibm.com \
/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