[PATCH v2 1/4] fs: Implement close-on-fork

2020-05-15 Thread Nate Karstens
descriptor with the close-on-fork flag set will be closed in the process that calls execve(2). Co-developed-by: Changli Gao Signed-off-by: Changli Gao Signed-off-by: Nate Karstens --- fs/fcntl.c | 4 +- fs/file.c | 64

[PATCH v2 3/4] fs: Add F_DUPFD_CLOFORK to fcntl(2)

2020-05-15 Thread Nate Karstens
Implement functionality for duplicating a file descriptor and having the close-on-fork flag automatically set in the new file descriptor. Signed-off-by: Nate Karstens --- fs/fcntl.c | 4 include/uapi/linux/fcntl.h | 3 +++ tools/include/uapi/linux/fcntl.h | 3

[PATCH v2] Implement close-on-fork

2020-05-15 Thread Nate Karstens
Series of 4 patches to implement close-on-fork. Tests have been published to https://github.com/nkarstens/ltp/tree/close-on-fork and cover close-on-fork functionality in the following syscalls: * accept(4) * dup3(2) * fcntl(2) * open(2) * socket(2) * socketpair(2) * unshare(2) Addresses

[PATCH v2 4/4] net: Add SOCK_CLOFORK

2020-05-15 Thread Nate Karstens
Implements a new socket flag that automatically sets the close-on-fork flag for sockets created using socket(2), socketpair(2), and accept4(2). Signed-off-by: Nate Karstens --- include/linux/net.h | 3 ++- net/socket.c| 14 -- 2 files changed, 10 insertions(+), 7 deletions

[PATCH v2 2/4] fs: Add O_CLOFORK flag for open(2) and dup3(2)

2020-05-15 Thread Nate Karstens
Add the O_CLOFORK flag to open(2) and dup3(2) to automatically set the close-on-fork flag in the new file descriptor, saving a separate call to fcntl(2). Co-developed-by: Changli Gao Signed-off-by: Changli Gao Signed-off-by: Nate Karstens --- arch/alpha/include/uapi/asm/fcntl.h| 2