Question about execve.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Helge,

On PARISC I'm seeing the following reproducible behvaiour:

* Parent calls vfork()
* Child of vfork() calls execve()
* Child returns from execve() and starts corrupting parent state
eventually leading to a segmentation fault.
* New process (as a result of execve) runs to completion.

What code in the Linux kernel prevents the child, which calls
execve(), from returning?

Test case attached.

Cheers,
Carlos.

Attachment: build.sh
Description: Bourne shell script

Attachment: pt-vfork.S
Description: Binary data

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

#define CALL_EXIT 0

int main (void)
{
  pid_t child;
  char *cmd[] = { "bash", "-c", "echo In child $$;", (char *)0 };
  char *env[] = { "HOME=/tmp", (char *)0 };
  int ret;

  child = vfork();

  if (child == 0)
    {
      ret = execve("/bin/bash", cmd, env);
      printf ("ret = %d\n", ret);
#if CALL_EXIT == 1
      _exit(1);
#endif
    }
  else
    {
      printf("child != 0\n");
    }

  printf("parent is %d\n", (unsigned int)getpid());
  printf("child is %d\n", (unsigned int)child);

  return 0;
}

[Index of Archives]     [Linux SoC]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux