[patch] ia64/clone2: make sure child_stack is non-NULL

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[patch] ia64/clone2: make sure child_stack is non-NULL

Mike Frysinger
playing with uClibc/ia64 and i noticed that a test case we have for testing
the return value of clone() when given bum arguments was failing ... seems
the clone2() function in ia64 never verifies child_stack like all other
architectures

attached patch adds a check for child_stack alongside the check for
child_fn ... i know squat about ia64 assembly so i'd be surprised if this was
correct :)
-mike

2006-02-22  Mike Frysinger  <[hidden email]>

        * sysdeps/unix/sysv/linux/ia64/clone2.S (__clone2): Make sure the child
        stack is not NULL.

--- sysdeps/unix/sysv/linux/ia64/clone2.S
+++ sysdeps/unix/sysv/linux/ia64/clone2.S
@@ -32,10 +32,12 @@ ENTRY(__clone2)
  .prologue
  alloc r2=ar.pfs,8,1,6,0
  cmp.eq p6,p0=0,in0
+ cmp.eq p7,p0=0,in1
  mov r8=EINVAL
  mov out0=in3 /* Flags are first syscall argument. */
  mov out1=in1 /* Stack address. */
-(p6) br.cond.spnt.many __syscall_error
+(p6) br.cond.spnt.many __syscall_error /* no NULL function pointers */
+(p7) br.cond.spnt.many __syscall_error /* no NULL stack pointers */
  ;;
  mov out2=in2 /* Stack size. */
  mov out3=in5 /* Parent TID Pointer */
Reply | Threaded
Open this post in threaded view
|

Re: [patch] ia64/clone2: make sure child_stack is non-NULL

H.J. Lu-27
On Wed, Feb 22, 2006 at 08:19:56PM -0500, Mike Frysinger wrote:
> playing with uClibc/ia64 and i noticed that a test case we have for testing
> the return value of clone() when given bum arguments was failing ... seems
> the clone2() function in ia64 never verifies child_stack like all other
> architectures
>
> attached patch adds a check for child_stack alongside the check for
> child_fn ... i know squat about ia64 assembly so i'd be surprised if this was
> correct :)
> -mike

Can you also provide a patch for testcase?


H.J.

Reply | Threaded
Open this post in threaded view
|

Re: [patch] ia64/clone2: make sure child_stack is non-NULL

Mike Frysinger
On Wednesday 22 February 2006 21:23, H. J. Lu wrote:

> On Wed, Feb 22, 2006 at 08:19:56PM -0500, Mike Frysinger wrote:
> > playing with uClibc/ia64 and i noticed that a test case we have for
> > testing the return value of clone() when given bum arguments was failing
> > ... seems the clone2() function in ia64 never verifies child_stack like
> > all other architectures
> >
> > attached patch adds a check for child_stack alongside the check for
> > child_fn ... i know squat about ia64 assembly so i'd be surprised if this
> > was correct :)
>
> Can you also provide a patch for testcase?
testcase from uClibc is attached (not as a patch though)
-mike

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sched.h>

int child_fn(void *arg)
{
        fprintf(stderr, "in child_fn\n");
        exit(1);
}

int main(void)
{
        int r_clone, ret_errno;

#ifdef __ia64__
        r_clone = __clone2(child_fn, NULL, 0, 0, NULL, NULL, NULL);
#else
        r_clone = clone(child_fn, NULL, (int) NULL, NULL);
#endif

        ret_errno = errno;
        if (ret_errno != EINVAL || r_clone != -1) {
                fprintf(stderr, "clone: res=%d (wanted -1) errno=%d (wanted %d)\n",
                        r_clone, errno, EINVAL);
                return 1;
        }

        return 0;
}
Reply | Threaded
Open this post in threaded view
|

Re: [patch] ia64/clone2: make sure child_stack is non-NULL

Roland McGrath
Please file this in bugzilla and provide a patch adding a test case in
standard form using test-skeleton.c (it's easy to do).


Thanks,
Roland
Reply | Threaded
Open this post in threaded view
|

Re: [patch] ia64/clone2: make sure child_stack is non-NULL

Mike Frysinger
On Wednesday 22 February 2006 21:52, Roland McGrath wrote:
> Please file this in bugzilla and provide a patch adding a test case in
> standard form using test-skeleton.c (it's easy to do).

done, BZ2386

i put the test in posix/ because that's where the vfork/fork tests are located
but i'm not sure if that's the proper location ...
-mike