git: kernel: Implement O_CLOEXEC

Francois Tigeot ftigeot at crater.dragonflybsd.org
Tue Jul 31 00:26:43 PDT 2012


commit 6e4ea98e8a4f403762582bd657180d3bd3636505
Author: François Tigeot <ftigeot at wolfpond.org>
Date:   Mon Jul 30 22:39:46 2012 +0200

    kernel: Implement O_CLOEXEC
    
    * Using fcntl(2) just after open(2) is not enough to avoid race conditions
      in programs doing fork+exec sequences. Child processes may be created
      before fcntl() is run and inherit the parent's file descriptors.
    
    * In some circonstances this behavior may even create security issues.
    
    * O_CLOEXEC can be used to atomically set the close-on-exec flag for new
      file descriptors, avoiding the whole mess in the first place.
    
    * Fixes issue #2356
    
    Inspired-from: NetBSD

Summary of changes:
 lib/libc/sys/open.2     |   18 +++++++++++++++---
 sys/kern/vfs_syscalls.c |   12 ++++++++----
 sys/sys/fcntl.h         |    3 +++
 3 files changed, 26 insertions(+), 7 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/6e4ea98e8a4f403762582bd657180d3bd3636505


-- 
DragonFly BSD source repository





More information about the Commits mailing list