From f8f74aaa84cf33d05b40c83385fe8fbbd0e6ab49 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Tue, 17 Nov 2020 21:20:11 +0000 Subject: linux(4) clone(2): Correctly handle CLONE_FS and CLONE_FILES The two flags are distinct and it is impossible to correctly handle clone(2) without the assistance of fork1(). This change depends on the pwddesc split introduced in r367777. I've added a fork_req flag, FR2_SHARE_PATHS, which indicates that p_pd should be treated the opposite way p_fd is (based on RFFDG flag). This is a little ugly, but the benefit is that existing RFFDG API is preserved. Holding FR2_SHARE_PATHS disabled, RFFDG indicates both p_fd and p_pd are copied, while !RFFDG indicates both should be cloned. In Chrome, clone(2) is used with CLONE_FS, without CLONE_FILES, and expects independent fd tables. The previous conflation of CLONE_FS and CLONE_FILES was introduced in r163371 (2006). Discussed with: markj, trasz (earlier version) Differential Revision: https://reviews.freebsd.org/D27016 --- sys/sys/proc.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sys/sys') diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 0b41b84c08ab..c593b500599c 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1017,7 +1017,8 @@ struct fork_req { int fr_pd_flags; struct filecaps *fr_pd_fcaps; int fr_flags2; -#define FR2_DROPSIG_CAUGHT 0x00001 /* Drop caught non-DFL signals */ +#define FR2_DROPSIG_CAUGHT 0x00000001 /* Drop caught non-DFL signals */ +#define FR2_SHARE_PATHS 0x00000002 /* Invert sense of RFFDG for paths */ }; /* -- cgit v1.2.3