From nobody Thu Nov 11 05:04:37 2021 X-Original-To: bugs@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 8F26B185538D for ; Thu, 11 Nov 2021 05:04:37 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HqV5137Vqz3HrV for ; Thu, 11 Nov 2021 05:04:37 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) 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 4C2CC260A1 for ; Thu, 11 Nov 2021 05:04:37 +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 1AB54bW0042435 for ; Thu, 11 Nov 2021 05:04:37 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 1AB54bef042434 for bugs@FreeBSD.org; Thu, 11 Nov 2021 05:04:37 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: bugs@FreeBSD.org Subject: [Bug 259770] stable/12: jail(2) failures after ca9ab8ea1774 Date: Thu, 11 Nov 2021 05:04:37 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: Unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: fk@fabiankeil.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: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: 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: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D259770 Bug ID: 259770 Summary: stable/12: jail(2) failures after ca9ab8ea1774 Product: Base System Version: Unspecified Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: fk@fabiankeil.de ElectroBSD contains patches for ggatec and ggated to drop privileges using jail(2). After rebasing from stable/11 to stable/12 this stopped working for ggated but not for ggatec. The problem seems to be caused by: | commit ca9ab8ea17748a1758701fde262cb272fb757989 | Author: Jamie Gritton | Date: Fri Feb 19 14:13:35 2021 -0800 | | MFC jail: Change both root and working directories in jail_attach(2) | | jail_attach(2) performs an internal chroot operation, leaving it up to | the calling process to assure the working directory is inside the jai= l. | | Add a matching internal chdir operation to the jail's root. Also | ignore kern.chroot_allow_open_directories, and always disallow the | operation if there are any directory descriptors open. | | Reported by: mjg | Approved by: markj, kib One of the differences between ggated and ggatec that is probably relevant is that ggated uses pidfile_open(). Is jail(2) expected to work for applications using the pidfile family of functions with pid files located outside the jail directory? Currently the struct returned by pidfile_open() contains a file descriptor to the directory containing the pid file which I suspect is the problem. ElectroBSD's ggated tries to jail into /var/empty while the pid file is located in /var/run. Shouldn't pidfile_open()'s use of cap_rights_limit() make this acceptable? ElectroBSD's ggate[cd]-related patches are available at: They should apply cleanly on stable/12 e644c87aa. For testing purposes I added a -j option and a sysctl to toggle the behaviour added in ca9ab8ea1774: fk@t520 ~ $sudo ggated -v -j info: Listen on port: 3080. error: Unable to jail process in directory /var/empty error: Exiting. fk@t520 ~ $sudo sysctl kern.pwd_chroot_chdir_check_open_directories=3D0 kern.pwd_chroot_chdir_check_open_directories: 1 -> 0 fk@t520 ~ $sudo ggated -v -j info: Listen on port: 3080. debug: Privileges successfully dropped using jail+setgid+setuid. I've previously posted the above to freebsd-stable@ and was asked by jamie@ to open a bug report. --=20 You are receiving this mail because: You are the assignee for the bug.=