From nobody Mon Dec 16 14:45:48 2024 X-Original-To: dev-commits-src-main@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 4YBjRd2hfjz5hWTD; Mon, 16 Dec 2024 14:45:49 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YBjRd063Jz4dK8; Mon, 16 Dec 2024 14:45:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734360349; 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=RKzN52J/BgtSXKBMd0JTYVA2zLc06VCYGPdEXhBsQd4=; b=Pe9ssmt0DY1VB+MCa7mZS58B2xDmHbz5E2d+4iRxL4rCElrLEy28urg9ycwZCRYscApWG0 rWi/8pBleVvMoIlpLDdVWCpszBIGrZ1+eAFLb28/V6kio6MDYFUugoIXtJ9zolKin3revg cF4jEHcZ12ZBf0pv6HYk8QXfn0g2XiR6BTiTe/KVMrNLhtZ5b8gqB2MY8T1SP+kmoIGJkf iqz25VHBBaoa2Zcq19j0T12MBXmpWqbvFru9WaMu6OC4DQFdQSiAaPVY6pBsshcs/ZdySu rbEl16D1fdHoMzbbI2eWhhUOMq2aOjU5D+mjJHz8clQnEZUug2K2dewotKyblg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734360349; 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=RKzN52J/BgtSXKBMd0JTYVA2zLc06VCYGPdEXhBsQd4=; b=ZNgAnbhUnOMMMkZRgxANJMZzNo1bXgiWpZWeLhX2JHvqsMCeafPs8kISIC75hod3Nr2yNe WhQurHXelzE99B0fZ9CboE1+8/LTmABA41J90YzewMSI70u0eN0tStD9BBrRvM9bOA5BEs L++LcTVXwz5MxsQcJ2TOGV+PHEw9eOfr37Zd77OD8f750XyU50KI5gjK+xgO8iONKKz5w/ Olj+66yZUAQJ2nH6QmBmW16bqs9zPbMop7FcV1ERArMvJKkK74+YfXdibDVA4d6doSc3zM fQIMKDje4fh3qJgc8ivuM/CgPTzlyCFNrDlomy1FwzVvqXCsYZCP8/6HHCuy5g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734360349; a=rsa-sha256; cv=none; b=q747pdnpAJ20zs7D7ezjqTAe5QxOwWFqchvjx+BD9FhoPhR8jfpWpge+mu3ich1iXegKiH YO3IN+t9UtGR93zHPgTB2Ui447+snjh7ZeycbMkHuXdwp7fSAXciAREYnbHOCUhLHQej8f J1FMrG0sFiqO9Xc8D/kGiP7sukk/9vdDT4hk3xxELXzOc8dwFQDAz/e1HE1wEjMkivtnnB aI9+5vSHbaWIAyYO3/iPVclA6TpcCoHJkUlJWDS/iX2hJIP/qRwAeVWBB+zYDkPARHe4Hr v0jhQMnkcADmisjimIJcxXR88SoWftf0x7Fa8zBwgKgzpC92azG/pmlQ1f78/A== 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 4YBjRc6jZmzxnL; Mon, 16 Dec 2024 14:45:48 +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 4BGEjmWK052967; Mon, 16 Dec 2024 14:45:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BGEjmVq052964; Mon, 16 Dec 2024 14:45:48 GMT (envelope-from git) Date: Mon, 16 Dec 2024 14:45:48 GMT Message-Id: <202412161445.4BGEjmVq052964@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: 53d2e0d48549 - main - MAC/do: sysctl_rules(): Set the requesting's thread's jail's rules List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 53d2e0d4854997005271ee60791ab114bd6e0099 Auto-Submitted: auto-generated The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=53d2e0d4854997005271ee60791ab114bd6e0099 commit 53d2e0d4854997005271ee60791ab114bd6e0099 Author: Olivier Certner AuthorDate: 2024-07-03 12:59:12 +0000 Commit: Olivier Certner CommitDate: 2024-12-16 14:42:35 +0000 MAC/do: sysctl_rules(): Set the requesting's thread's jail's rules Allowing to change the rules specification on a jail other than the requesting's thread one is a security issue, as it will immediately apply to the jail we inherited from and all its other descendants that inherit from it. With this change, setting the 'mdo_rules' sysctl in a jail forces that jail to no more inherit from its parent. Reviewed by: bapt Approved by: markj (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D47601 --- sys/security/mac_do/mac_do.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/security/mac_do/mac_do.c b/sys/security/mac_do/mac_do.c index 94fe7b99fc9d..98bace7052f6 100644 --- a/sys/security/mac_do/mac_do.c +++ b/sys/security/mac_do/mac_do.c @@ -310,11 +310,12 @@ static int sysctl_rules(SYSCTL_HANDLER_ARGS) { char *const buf = malloc(MAC_RULE_STRING_LEN, M_DO, M_WAITOK); + struct prison *const td_pr = req->td->td_ucred->cr_prison; struct prison *pr; struct rules *rules; int error; - rules = find_rules(req->td->td_ucred->cr_prison, &pr); + rules = find_rules(td_pr, &pr); strlcpy(buf, rules->string, MAC_RULE_STRING_LEN); prison_unlock(pr); @@ -322,7 +323,8 @@ sysctl_rules(SYSCTL_HANDLER_ARGS) if (error != 0 || req->newptr == NULL) goto out; - error = parse_and_set_rules(pr, buf); + /* Set our prison's rules, not that of the jail we inherited from. */ + error = parse_and_set_rules(td_pr, buf); out: free(buf, M_DO); return (error);