All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/1] Containers: Pass a valid stack address to clone
@ 2009-09-02 14:10 Serge E. Hallyn
  2009-09-02 20:13 ` Mike Frysinger
  0 siblings, 1 reply; 4+ messages in thread
From: Serge E. Hallyn @ 2009-09-02 14:10 UTC (permalink / raw)
  To: Subrata Modak1; +Cc: LTP list, Nathan T Lynch

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH 1/1] Containers: Pass a valid stack address to clone
  2009-09-02 14:10 [LTP] [PATCH 1/1] Containers: Pass a valid stack address to clone Serge E. Hallyn
@ 2009-09-02 20:13 ` Mike Frysinger
  2009-09-07 11:40   ` Subrata Modak
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Frysinger @ 2009-09-02 20:13 UTC (permalink / raw)
  To: ltp-list; +Cc: Subrata Modak1, Nathan T Lynch


[-- Attachment #1.1: Type: Text/Plain, Size: 632 bytes --]

On Wednesday 02 September 2009 10:10:27 Serge E. Hallyn wrote:
> 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.

please, let's stop screwing around with this and copying & pasting it 
everywhere.  create a new dedicate "ltp_clone" or similar function and stick 
the arch-specific logic there.
int ltp_clone(func ptr, stack base, stack size, clone flags, func args...)
-mike

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 355 bytes --]

------------------------------------------------------------------------------
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

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH 1/1] Containers: Pass a valid stack address to clone
  2009-09-02 20:13 ` Mike Frysinger
@ 2009-09-07 11:40   ` Subrata Modak
  2009-09-08  4:53     ` Serge E. Hallyn
  0 siblings, 1 reply; 4+ messages in thread
From: Subrata Modak @ 2009-09-07 11:40 UTC (permalink / raw)
  To: Serge E. Hallyn; +Cc: ltp-list, Nathan T Lynch, Mike Frysinger

On Wed, 2009-09-02 at 16:13 -0400, Mike Frysinger wrote: 
> On Wednesday 02 September 2009 10:10:27 Serge E. Hallyn wrote:
> > 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.
> 
> please, let's stop screwing around with this and copying & pasting it 
> everywhere.  create a new dedicate "ltp_clone" or similar function and stick 
> the arch-specific logic there.
> int ltp_clone(func ptr, stack base, stack size, clone flags, func args...)
> -mike
> -----------------------

Serge,

Did you post any new patches after Mikeś comments ?

Regards--
Subrata

> -------------------------------------------------------
> 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


------------------------------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH 1/1] Containers: Pass a valid stack address to clone
  2009-09-07 11:40   ` Subrata Modak
@ 2009-09-08  4:53     ` Serge E. Hallyn
  0 siblings, 0 replies; 4+ messages in thread
From: Serge E. Hallyn @ 2009-09-08  4:53 UTC (permalink / raw)
  To: Subrata Modak; +Cc: ltp-list, Nathan T Lynch, Mike Frysinger

Quoting Subrata Modak (subrata@linux.vnet.ibm.com):
> On Wed, 2009-09-02 at 16:13 -0400, Mike Frysinger wrote: 
> > On Wednesday 02 September 2009 10:10:27 Serge E. Hallyn wrote:
> > > 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.
> > 
> > please, let's stop screwing around with this and copying & pasting it 
> > everywhere.  create a new dedicate "ltp_clone" or similar function and stick 
> > the arch-specific logic there.
> > int ltp_clone(func ptr, stack base, stack size, clone flags, func args...)
> > -mike
> > -----------------------
> 
> Serge,
> 
> Did you post any new patches after Mikeś comments ?

No I haven't.  I agree with him, and see other cases which could
stand consolidation under syscalls/clone, fs/fs_bind/nsclone,
controllers/cgroup, security/tomoyo, security/selinux-testsuite,
audit-test, and misc/crash.

-serge

------------------------------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-09-08  4:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-02 14:10 [LTP] [PATCH 1/1] Containers: Pass a valid stack address to clone Serge E. Hallyn
2009-09-02 20:13 ` Mike Frysinger
2009-09-07 11:40   ` Subrata Modak
2009-09-08  4:53     ` Serge E. Hallyn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.