]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
linux(4) clone(2): Correctly handle CLONE_FS and CLONE_FILES
authorcem <cem@FreeBSD.org>
Tue, 17 Nov 2020 21:20:11 +0000 (21:20 +0000)
committercem <cem@FreeBSD.org>
Tue, 17 Nov 2020 21:20:11 +0000 (21:20 +0000)
commit10dd999b1bce669e79e9abd738a37e5137bc110d
treeb666c7ee2cbe33f3eb298fb3823341d7d24c51ee
parentf0d3db347bc80261caeca5c8624430717012f347
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/compat/linux/linux_fork.c
sys/kern/kern_fork.c
sys/sys/proc.h