From nobody Sun Oct 13 23:46:17 2024 X-Original-To: dev-commits-src-branches@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 4XRcSp1ztwz5Ym0L; Sun, 13 Oct 2024 23:46:18 +0000 (UTC) (envelope-from git@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 4XRcSp1BgZz41Gt; Sun, 13 Oct 2024 23:46:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728863178; 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; bh=jg17VrNFXOdGuiHKg7KWXuaiMepF8tcotueJLGw5FkY=; b=letUOX2zTflMsHTTYHdBxxoPQkVUX+SospZycg3rCm1u5hGiGGFD/MRP+Xt1CRu/6k2Kph DELo7EfTy0OZcEkFOgrP3qIokkwez5ijAEMI/pUFMpGYgtK/TJAHgKNLKCAgv1MSDYUg9W 1KQ4PyJwROjAPGILmrpbxuSdzyUWa7D/3QuJhCkcgSd4Cun+Nu6y0jJq+G9HwYgc+sk1Ql pzv32lhKkfQzE6hgVlOx6CcnsEVyqzcfGq0GNjruB04uUTWHrfpLLjlkzy8Co9pLn1X9UH vfoHyNYz/mEkTpkKZrEMH7qi01Xl2SjIR2g9s1K9QjNM9ZxN688bAUsJJfx9Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728863178; 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; bh=jg17VrNFXOdGuiHKg7KWXuaiMepF8tcotueJLGw5FkY=; b=xQCXy217HsCfMa6dXFvrWnRkrFNx7vAbXzn9Bvv9qaY+PLgoIIK0gDDOUXucuwf6GOajd1 /JL1nAQr/R8jMeK0hyuffulBfQL2Y/3OC6wJsij6cFbT9S7Qd043uXLZCfE13EbVgMWVHp uO3/EitNkPGnobPBL8oOgjtTKHXFQlkOILO8HzmaMobwvlf84x8UraW6XGqy6gJRwC9cMc GhwP1F1ar7lxQOeez5KqujUXaQ3Dh9UlUhmw1BmnhfqnZ+PJCvlBKEn+49Pk2k51KnZT1m U5Iwb9NMYdc4dc4Li8f/aDD+Ao5b8tqN9ruwUWkDrQL7Z2ljbq6zidkvK9hTnA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728863178; a=rsa-sha256; cv=none; b=SP+0xRMqsDVr93uCq/9XajFj0gSpB9YM4ZVWfv+fBrUxlZVXqJlEH633yomSlRl0yPQtS0 fYhWBLVa2z54C6K+5s1XSsznD0fYWY851YzquaXcwBMpk9M5uy+0IeR7xBDcG0rDErYNhT 0vZ7xUuw0e7gjMsj3SID+wN6wl1mdAld9TTwE1i6iUCW8Z1dpLTAN2EGgegK8gdz+dV9Hl 3DPbr3UcmMkO00RbcaVZM0R6TMq2pwD2XtJ2LO285TScgSRXRlWG8Fy0ciqre4+GRsJX+n 2hTAvxA/Hs6uAJp7J2ClMm3a6H3V0Zp6N/JekR2Hl8WQvoyr8tcu0wA5woeE6g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 4XRcSp0ggXzDnw; Sun, 13 Oct 2024 23:46:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49DNkHbZ066052; Sun, 13 Oct 2024 23:46:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49DNkHEG066049; Sun, 13 Oct 2024 23:46:17 GMT (envelope-from git) Date: Sun, 13 Oct 2024 23:46:17 GMT Message-Id: <202410132346.49DNkHEG066049@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jamie Gritton Subject: git: 16e1424d24b9 - stable/14 - jail: expose children.max and children.cur via sysctl List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jamie X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 16e1424d24b9ab6e90f0bbb5d1a8d11479ea34e5 Auto-Submitted: auto-generated The branch stable/14 has been updated by jamie: URL: https://cgit.FreeBSD.org/src/commit/?id=16e1424d24b9ab6e90f0bbb5d1a8d11479ea34e5 commit 16e1424d24b9ab6e90f0bbb5d1a8d11479ea34e5 Author: Jamie Gritton AuthorDate: 2024-10-13 23:45:58 +0000 Commit: Jamie Gritton CommitDate: 2024-10-13 23:45:58 +0000 jail: expose children.max and children.cur via sysctl Submitted by: Igor Ostapenko Differential Revision: (cherry picked from commit ab0841bdbe8460db6eb77e0228a08812ce74d583) --- sys/kern/kern_jail.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index 1f775f78e581..a4bd27734e8e 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -4425,6 +4425,35 @@ SYSCTL_PROC(_security_jail, OID_AUTO, devfs_ruleset, sysctl_jail_default_level, "I", "Ruleset for the devfs filesystem in jail (deprecated)"); +SYSCTL_NODE(_security_jail, OID_AUTO, children, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, + "Limits and stats of child jails"); + +static int +sysctl_jail_children(SYSCTL_HANDLER_ARGS) +{ + struct prison *pr; + int i; + + pr = req->td->td_ucred->cr_prison; + + switch (oidp->oid_kind & CTLTYPE) { + case CTLTYPE_INT: + i = *(int *)((char *)pr + arg2); + return (SYSCTL_OUT(req, &i, sizeof(i))); + } + + return (0); +} + +SYSCTL_PROC(_security_jail_children, OID_AUTO, max, + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, + NULL, offsetof(struct prison, pr_childmax), sysctl_jail_children, + "I", "Maximum number of child jails"); +SYSCTL_PROC(_security_jail_children, OID_AUTO, cur, + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, + NULL, offsetof(struct prison, pr_childcount), sysctl_jail_children, + "I", "Current number of child jails"); + /* * Nodes to describe jail parameters. Maximum length of string parameters * is returned in the string itself, and the other parameters exist merely