From nobody Fri Nov 20 15:10:48 2026 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 4jWJgY2r2Qz71yQ7 for ; Fri, 20 Nov 2026 15:10: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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jWJgX5ydFz4j4K for ; Fri, 20 Nov 2026 15:10:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795187448; 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=U4mEZo573zTrPZe+z9c2hRpHU/hmKN88tVf8X6nmq8E=; b=Ho2NjGYHHEFfwzwm8T6mTDS0AyhGvy9anONmO+oiuLPKQA+A7YN6pOIdFE7hAmCbbkB1EK i8Y495dEk6in96h4+yioAtmdBhBYYzQ6Qz/Z/Rrs1tJpwsxXL69ZY0WM4EHLWyox1dqj90 0YErRNCafl4UkR1YWD8+lKMzxQGe8Pe/HhmIeR8e0x8MV5V/YMa3K8sOKY8+nVgualPRLI 1MAeRFq3E5wSyKlehmQA+m45/vi8MXK9EtU3EnDLzDktDofFEszlwGevhrMB3ZMDz/nHUp 0AIUAhUBq/M7Q/H0Czuu7d87CzTZF3DN9deQD7opxaOqEimuA3zSt0Pz8JMwYQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795187448; b=VjgUsipFYMUl5SSM4+NxWvkdf3ca2iKLtTtNjwbwTibPQ0ketKBsBM2XVy+0uevse/pj5x NAHUV/+kkyrEyq3cj+zxUxlNsJgInNL2QG8cCYzoPbt2YpGQwuOVWl6eWI9zan9x5np6bl OawXU16UV6N+/MsVyDmzY5qOkA96GIdQ9eNas3kaXjpR7iQStC8mgHdV6rI0Kgs+v0aY3H HWqXru0GMBjVaIbv8HVabTvYkH1wJlidQMVA1oEMcmi+Z0yyyiTO7KtkDIx03JS0Gr591Q zgexAs9WeKvTw82xXxo3HjT95N4fCHUizFFq2Tj5eD1CG5LUJOCm5jXpcdoDGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795187448; 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=U4mEZo573zTrPZe+z9c2hRpHU/hmKN88tVf8X6nmq8E=; b=uavH8HnWzbc7QafoK3LEH882WPVot4an6f9WaO4PQS2YSIvVB6lEerIE/tdYs1VFj8et0E VIE6PI64NqYlsg94rbEEfNShxkua6QtxeIzH9eYjIgA17FkfY0Ht7SoBIk/Qhvjbr2BuiF FURavOjt07e7vVSLWTa/Ux5ckVlrJJQulqsS/N7HRb+UajNa23e1bX2SrNV3nDfNkC9ZPZ jDGywQHfQLnvCNSSsxdkohrnYt2p+33OUbDwuLvsrCvmR4bsYOl2FJgJnSl3yTEodU78L2 mPjTggzQl1uWqbF4hL6IE8GhLIJlQJcb+klNoow/Mw2RP0XTdv7mJ6Czwd1S6w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jWJgX5dF9zt7c for ; Fri, 20 Nov 2026 15:10:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 18757 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 20 Nov 2026 15:10:48 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 2137bad49a6f - main - exec_new_vmspace(): drop altroot for native processes if setuid List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2137bad49a6f4336cbc6c4045fdaf408dcc96f06 Auto-Submitted: auto-generated Date: Fri, 20 Nov 2026 15:10:48 +0000 Message-Id: <6b0062f8.18757.2fdd5dbd@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2137bad49a6f4336cbc6c4045fdaf408dcc96f06 commit 2137bad49a6f4336cbc6c4045fdaf408dcc96f06 Author: Konstantin Belousov AuthorDate: 2026-09-28 21:53:05 +0000 Commit: Konstantin Belousov CommitDate: 2026-11-20 15:10:26 +0000 exec_new_vmspace(): drop altroot for native processes if setuid Noted and reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D60035 --- sys/kern/kern_exec.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 7871ac9b86fa..390f4cdaf3ed 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1265,6 +1265,20 @@ exec_new_vmspace(struct image_params *imgp, struct sysentvec *sv) imgp->vmspace_destroyed = true; imgp->sysent = sv; + /* + * Drop altroot if setuid. It is done so late to avoid + * clearing altroot until there is no way for execve(2) to + * return to the calling image. + * + * Setuid is ignored for P2_NO_NEW_PRIVS processes, but + * credential_setid is only cleared by execve_nosetid() after + * the image activator returns, so check the flag here. + */ + if (imgp->credential_setid && + (p->p_flag2 & P2_NO_NEW_PRIVS) == 0 && + (sv->sv_flags & SV_ABI_MASK) == SV_ABI_FREEBSD) + pwd_altroot(td, NULL); + if (p->p_sysent->sv_onexec_old != NULL) p->p_sysent->sv_onexec_old(td); itimers_exec(p);