From nobody Sun Feb 12 11:46:51 2023 X-Original-To: dev-commits-src-all@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 4PF5Kl2nPVz3pDKJ; Sun, 12 Feb 2023 11:46:51 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PF5Kl219Qz41F9; Sun, 12 Feb 2023 11:46:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676202411; 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=JJMrtXvY3x3/ydVMTe3VE4AveL8Xsc6yOeU/efYvCBM=; b=p1NDJjtllnS33yf8iOofRGl6Muj2bSXDhrGBg9zfXrProvpreMGvCeC5iHUYjXVNF5Iyop wj7+7ADiB4Rebz6wglioiV3Sie5rO1UDg7u6BB92zwa8h9sAnS0jvE5VrOZ77JFbZc8S96 sdJN2r9lmE+hwfU1RM8JAo1l6Av3LUAqS4qYj2WJRN1d9UsJR4toxLqgr3L+THvt+Qf/ZJ 4MzIdI5ZfXWuMeaRCyPEXngideQKjsNSHPhAMDZXyTo0Pws8El97GJ9qsJ8NVGinIMUB6n Q5doIuwJkCoRHaW/ZTJ/2kDg8Dmv/uBWeCDCkqe2RJXUDSWEkN1SjRHcRjLB/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676202411; 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=JJMrtXvY3x3/ydVMTe3VE4AveL8Xsc6yOeU/efYvCBM=; b=eDb9uEIQTGi35XTbRK6kzWf/ygY4B3QBD1uF5iU7OdHXORJJowpaTQ3+BAv9aGZxnTg1M3 4bqwaZAT/A0o1/ZeyvAJX8jJCppzi+ttToSQUnHSLtRE1WRwoVn9LpGIK62cren1HjcADa 64Xhu/zC/xMeUcwBqn/djSVHevaXd8p3jTA47csuXgmp24PuN9bo8MjOj8a+9SKkAtingA CVSw4L8vyg9BFDvU7t2aHwEsX44xYAX9Y4D0wf7ASlRQAlTluUwuw4Q5xBZF2hWW/9LjbI lC2rfLGLPBY5fE63/xjkmoEIZU2yTk08p1SG1RY+g2SaWFT/avkCWPD0jTqmYQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676202411; a=rsa-sha256; cv=none; b=lwCemwkYuoNLsycziCDnMBQ7ttpWNgtqBxUbd7nupS6DRo3aW1vEuSsldnu94uKnluZQhr lGHjBUuwe7D0gY4pbL/xPheSTxr2PG8GGZ1v0Ptj3Te2zsGB5Acoz9biVfYlw8ZauzQPuG F8aEuZMhZ84aTRUN2e0ZSNO9MxEYdSWPrsQNsCP84PhlLEJD3GlFlZTu/XrqLPqLFP9iDD aXULxBbYrMcDTg044dLGqYaYflcO2ngWElzwS8InURjMLe+mjOgq4H3rpVy1s+DY5UkAKT Li6G2mDV4Ik0zbCV9+6HaNNqZV+HLR+RFw6auaa3TaYukycLonbxfLNiytmpZA== 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 4PF5Kl15dLzcmP; Sun, 12 Feb 2023 11:46:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 31CBkpnm096388; Sun, 12 Feb 2023 11:46:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31CBkprW096387; Sun, 12 Feb 2023 11:46:51 GMT (envelope-from git) Date: Sun, 12 Feb 2023 11:46:51 GMT Message-Id: <202302121146.31CBkprW096387@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 69e7d9b7e6b3 - main - fibs: restrict jail_attach(2) if process fibnum >= numfibs in the jail. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 69e7d9b7e6b369b760e1f189af2e25587b56a102 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=69e7d9b7e6b369b760e1f189af2e25587b56a102 commit 69e7d9b7e6b369b760e1f189af2e25587b56a102 Author: Alexander V. Chernikov AuthorDate: 2023-02-11 15:43:23 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-02-12 11:46:38 +0000 fibs: restrict jail_attach(2) if process fibnum >= numfibs in the jail. Reported by: olivier Tested by: olivier Reviewed by: kp, glebius Differential Revision: https://reviews.freebsd.org/D38505 MFC after: 1 week --- sys/net/route/route_tables.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/sys/net/route/route_tables.c b/sys/net/route/route_tables.c index 637a86573320..be67556915d0 100644 --- a/sys/net/route/route_tables.c +++ b/sys/net/route/route_tables.c @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -162,6 +163,39 @@ sys_setfib(struct thread *td, struct setfib_args *uap) return (error); } +static int +rtables_check_proc_fib(void *obj, void *data) +{ + struct prison *pr = obj; + struct thread *td = data; + int error = 0; + + if (TD_TO_VNET(td) != pr->pr_vnet) { + /* number of fibs may be lower in a new vnet */ + CURVNET_SET(pr->pr_vnet); + if (td->td_proc->p_fibnum >= V_rt_numfibs) + error = EINVAL; + CURVNET_RESTORE(); + } + return (error); +} + +static void +rtables_prison_destructor(void *data) +{ +} + +static void +rtables_init(void) +{ + osd_method_t methods[PR_MAXMETHOD] = { + [PR_METHOD_ATTACH] = rtables_check_proc_fib, + }; + osd_jail_register(rtables_prison_destructor, methods); +} +SYSINIT(rtables_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, rtables_init, NULL); + + /* * If required, copy interface routes from existing tables to the * newly-created routing table.