From nobody Mon May 18 15:25:42 2026 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 4gK1pZ6Ktgz6fWhH for ; Mon, 18 May 2026 15:25:42 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gK1pZ5r2xz3m2S for ; Mon, 18 May 2026 15:25:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779117942; 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=w+aU423KzhfskeR4B6d9RTtGcB1KztRFMANViUPlfk8=; b=bptrR30PyiZ5G18ik0oQDSKiak9sjII+rZPFL83H+fx0XUrqk2IH9gETn7/y0mn1SY6Sfv 0iwwuu5iqR5Q11lIvZJ4FQvj0eB6A0j5C6FVn4eeoqLdjvAZbo5tpTDmpmv4xY/4PFU9+l YhNkNhXfONKOpqn+ynSkbWoVF34dblpMHaWM2Fh39wkVeBJUmQ2DWk8OyT7QZBYc7B3xpU v52i4RiKjDGklvs4ZUrcf48HbMcO76e0Xam3SnfRDW/5x1m3VG5G+tWwKmsI6AAP5Qf3C4 7vmFxjICTmhbHarDnCMdlD6HaW1t+46glz5bgYaZ5TXDU9zS5Av0U4JJQHBVXA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1779117942; a=rsa-sha256; cv=none; b=Ij34giK4vU2o7LmvAhAvbwUNEoeWgET8161M1pl1GFg/zIXSiMOI1Kh9VLtpo8iJqoP/6L of0oTSe5pPFFT5TJsHPTf7foTYcFPsVJ0QmcGxc1P/D7nJK7Z7G50v2IuzRLU/HOHtQkEm 2X/YFLxFSEqfsnNxvz+qrQ1lSNwAxSreX5vlNShnz4mxitONX8YDtM0kKOY73lUAP10K2K YVQHnGwRMexxkXHCUTmBB1SuxPOhqG9YU6nr/7zN8uMc3XCCOnCuL9FYEcM9c1HDs6Vkei zCUg5qH+jDEWMB1mT67m+e1y5pdkIACsDaDTwZA15gkjyGWY+dKPtCl2YElTcQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779117942; 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=w+aU423KzhfskeR4B6d9RTtGcB1KztRFMANViUPlfk8=; b=Xc1bvRvJ7I9a806OrfPntK122/+TqICSUyutpCO235kMZIo2cPGakkbskYGuSdogY6z3xy NaqLRc4/uOyvBIx6YtiJH9C3fJOe6ZcA2qFK3xq8sBA8izH9RC9UIMros8wHYc6OyTo+ye d3MCA1eOYQB4/fZnsZO8nEuy6m1pSSGih2FfLTBf5k5X5NGm99B4MDrC7BoDpejV6FWYBV +3vupCTqZSzdKq4fabUfhKMDbbhUwUlAYvLGPYKJhF2TWPDnjQMjjt9K3TWUqYR7I2xYeK vS+QVOm3WU6jfBJmwQr6713jLtkcSBqWtHeVqTRXiUEcT8KIk+EJD+dmt98WSw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gK1pZ5Kg8zZvR for ; Mon, 18 May 2026 15:25:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 43916 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 18 May 2026 15:25:42 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mariusz Zaborski Subject: git: d705a519525f - main - cap_net: do not allow new limits to drop keys from the old ones 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 List-Id: 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: oshogbo X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d705a519525f2acae3c1efba11436ec6ee8aea0a Auto-Submitted: auto-generated Date: Mon, 18 May 2026 15:25:42 +0000 Message-Id: <6a0b2f76.43916.7efa6342@gitrepo.freebsd.org> The branch main has been updated by oshogbo: URL: https://cgit.FreeBSD.org/src/commit/?id=d705a519525f2acae3c1efba11436ec6ee8aea0a commit d705a519525f2acae3c1efba11436ec6ee8aea0a Author: Mariusz Zaborski AuthorDate: 2026-05-12 08:33:41 +0000 Commit: Mariusz Zaborski CommitDate: 2026-05-18 15:18:43 +0000 cap_net: do not allow new limits to drop keys from the old ones If the old limit had family/hosts/sockaddr set, the new limit must have them too. Before, a missing key in the new limit was treated as "allow any", which let a caller silently extend their limits. Reported by: Joshua Rogers of AISLE Research Team Reviewed by: markj MFC after: 1 day Differential Revision: https://reviews.freebsd.org/D56991 --- lib/libcasper/services/cap_net/cap_net.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/libcasper/services/cap_net/cap_net.c b/lib/libcasper/services/cap_net/cap_net.c index 59124e3cb54f..e04cad1d834c 100644 --- a/lib/libcasper/services/cap_net/cap_net.c +++ b/lib/libcasper/services/cap_net/cap_net.c @@ -1122,12 +1122,37 @@ net_connect(const nvlist_t *limits, nvlist_t *nvlin, nvlist_t *nvlout) return (0); } +/* + * If the old sublimit restricted a subkey, the new one must too; + * a missing subkey means "allow any" at request time. + */ +static bool +verify_subkeys_present(const nvlist_t *oldfunclimits, + const nvlist_t *newfunclimit) +{ + void *cookie; + const char *name; + + if (oldfunclimits == NULL) + return (true); + + cookie = NULL; + while ((name = nvlist_next(oldfunclimits, NULL, &cookie)) != NULL) { + if (!nvlist_exists(newfunclimit, name)) + return (false); + } + return (true); +} + static bool verify_only_sa_newlimts(const nvlist_t *oldfunclimits, const nvlist_t *newfunclimit) { void *cookie; + if (!verify_subkeys_present(oldfunclimits, newfunclimit)) + return (false); + cookie = NULL; while (nvlist_next(newfunclimit, NULL, &cookie) != NULL) { void *sacookie; @@ -1200,6 +1225,9 @@ verify_addr2name_newlimits(const nvlist_t *oldlimits, LIMIT_NV_ADDR2NAME, NULL); } + if (!verify_subkeys_present(oldfunclimits, newfunclimit)) + return (false); + cookie = NULL; while (nvlist_next(newfunclimit, NULL, &cookie) != NULL) { if (strcmp(cnvlist_name(cookie), "sockaddr") == 0) { @@ -1258,6 +1286,9 @@ verify_name2addr_newlimits(const nvlist_t *oldlimits, LIMIT_NV_NAME2ADDR, NULL); } + if (!verify_subkeys_present(oldfunclimits, newfunclimit)) + return (false); + cookie = NULL; while (nvlist_next(newfunclimit, NULL, &cookie) != NULL) { if (strcmp(cnvlist_name(cookie), "hosts") == 0) {