From nobody Mon Aug 19 11:15:23 2024 X-Original-To: doc@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WnVPl3l0pz5SpjK for ; Mon, 19 Aug 2024 11:15:23 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WnVPl1gZ3z4Wtq for ; Mon, 19 Aug 2024 11:15:23 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724066123; a=rsa-sha256; cv=none; b=MeDiKXhjRPrzk1eGbFTpVXibIOyT1R1iIs0dkO+FpoQYWIux/dayEiJ9pzHOkBVOI5DT8U qgTtEYnMEnZTyvN88ut1c8bWAMRjktSrNPlCSQ22QZYS3nWAs6Ec2Q3rWImBocxJq2KqWC QTDoS1DpfU64yTK/AWXeXZ9VItF/+yejQ/9GQcIqaFFBf/LI3K2AdB4QfIyKKWMn+FoAw3 ncKtPJhSqN6BLv2nVBn22yKiGi3mamIX+SOrF9CQ34ZXyX5D2nHK/Tr834kepvngxk68t5 8mL1b/bnbH09lPUxGWiWsNr3QYoyqEvhRS3KRx2sWdWyazEAjWYnMudT4v3vsw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724066123; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0HKDqCN3ENAzg6aFb0lg/Hz+5LzdgQI7dlvOYA9TNRk=; b=I+7gvKACkXoAmqHg9lqUdhVKqYqvr9ZjHHnrYtUXPVoFK45JqddTnNq0gp9xALXQj6pE1S vnP470ai3Xq8+mYGfKYGOr9hbDLnZwP3a0mIivlVfLVVxAwBPq87fadpfwmJHbXsX42LNi Kb6fohqWZ67UafXpDrlugfT81myuk6dhQeSESLQ5+TxlJHyL/dxRRbvWSRFhThDcDsoNA4 jVtvyP5HM++nuqpJ0DGReizCxmU/sMP0htRsDi1qCm3XnlEDad1d/Ewblnm20HdSk+W/rS oUj+KY5TjvDrC+IfxANrn9qUCxXosXk/ugL8RZu+CoL17aDSSZpkjbm7803p3Q== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WnVPl193JzDlJ for ; Mon, 19 Aug 2024 11:15:23 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 47JBFN88099858 for ; Mon, 19 Aug 2024 11:15:23 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 47JBFNQQ099857 for doc@FreeBSD.org; Mon, 19 Aug 2024 11:15:23 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: doc@FreeBSD.org Subject: [Bug 280809] jail_attach(2) fails to document reason for EPERM Date: Mon, 19 Aug 2024 11:15:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Documentation X-Bugzilla-Component: Manual Pages X-Bugzilla-Version: Latest X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: crest@rlwinm.de X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Documentation project List-Archive: https://lists.freebsd.org/archives/freebsd-doc List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-doc@FreeBSD.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D280809 --- Comment #3 from crest@rlwinm.de --- There is the kern.chroot_allow_open_directories sysctl to allow chroot() wi= th directory file descriptors, but no such "backdoor" exists for jail_attach(), because jails are supposed to provide secure namespace isolation. Removing = this restriction would allow trivial jail escapes through fchdir() and openat(). Allowing jailed processes to safely share directory file descriptors either through inheritance or file descriptor passing could be very useful, but is totally unsafe right now. Sharing directory file descriptors through inheritance across jails is (and always has been) impossible because jail_attach() doesn't allow processes with having one or more such file descriptors to attach to a jail. Despite this it's possible to share file descriptors across jails via file descriptor passing over unix domain socke= ts. Passing directory file descriptors to a directory outside the receivers jail root into a jail is an instant file system escape because the jail root is enforced by comparing vnodes and if you `parent_fd =3D openat(dir_fd, "..", O_DIRECTORY)` you won't encounter the jail root vnode. By looping until "."= =3D=3D ".." the jailed process can find the hosts root filesystem. While the unix socket could be brought into a jail via jail_attach() the more likely real world situation would be intentionally sharing a nullfs mount across jails (e.g. a PostgreSQL jail <-> a FastCGI jail). One way I can think of to make it safe would be to add a O_RESOLVE_BENEATH = like write-once flag to file descriptors and allow only directory file descripto= rs with this flag to be shared across jails. It would have to be inherited too (e.g. openat(dir_fd, "", O_DIRECTORY) on a sub-directory). If the f= lag could be automatically set by jail_attach() and file descriptor passing acr= oss jails would work without extra syscalls to set the new flag with the caveat that ".." inaccessible on such file descriptors and those derived from them. --=20 You are receiving this mail because: You are on the CC list for the bug.=