clone flags

John D. Ramsdell ramsdell at mitre.org
Thu Jul 19 13:24:09 UTC 2007


I've been carefully comparing output I obtain with autrace with what I
get from strace.  It appears they differ when the clone system call is
invoked from the C library via fork.  In particular, strace reports
flags of CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, while
autrace says the flags are 0.  The flags are in field a2.

John

[ramsdell at goo fork]$ uname -r
2.6.21-1.3228.fc7
[ramsdell at goo fork]$ make fork
cc     fork.c   -o fork
[ramsdell at goo fork]$ strace -o strace.txt ./fork
[ramsdell at goo fork]$ su -
Password: 
[root at goo ~]# cd /home/ramsdell/proj/fork
[root at goo fork]# autrace ./fork
Waiting to execute: ./fork
Cleaning up...
Trace complete. You can locate the records with 'ausearch -i -p 1160'
[root at goo fork]# ausearch -i -p 1160 > autrace.txt
[root at goo fork]# grep clone strace.txt 
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb7efb708) = 1122
[root at goo fork]# grep clone autrace.txt 
type=SYSCALL msg=audit(07/19/2007 09:16:02.350:848) : arch=i386 syscall=clone success=yes exit=1161 a0=1200011 a1=0 a2=0 a3=0 items=0 ppid=1158 pid=1160 auid=ramsdell uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=pts2 comm=fork exe=/home/ramsdell/proj/fork/fork subj=user_u:system_r:unconfined_t:s0 key=(null) 
[root at goo fork]# cat fork.c 
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>

int main(int argc, char **argv)
{
  int status;
  pid_t pid;
  switch (fork()) {
  case -1:
    perror("clone");
    return 1;
  case 0:
    return 0;
  default:
    do {
      pid = wait(&status);
    } while (pid < 0 && errno == EINTR);
    if (WIFEXITED(status))
      return WEXITSTATUS(status);
    else
      return 1;
  }
}
[root at goo fork]# 




More information about the Linux-audit mailing list