git: acd860c3622d - releng/13.2 - cap_net: correct capability name from addr2name to name2addr
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 08 Nov 2023 00:53:01 UTC
The branch releng/13.2 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=acd860c3622d2591f4eeaaf241094c311c5c642a commit acd860c3622d2591f4eeaaf241094c311c5c642a Author: Mariusz Zaborski <oshogbo@FreeBSD.org> AuthorDate: 2023-10-23 21:03:51 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2023-11-08 00:49:31 +0000 cap_net: correct capability name from addr2name to name2addr Previously, while checking name2addr capabilities, we mistakenly used the addr2name set. This error could cause a process to inadvertently reset its limitations. Reported by: Shawn Webb <shawn.webb@hardenedbsd.org> (cherry picked from commit afd74c400075d94e01dd3430844bb290834660ef) (cherry picked from commit 765757c6301fa41c0b59108347c600fbc9020c39) (cherry picked from commit 114c6d9bef765a47ebcb8e65d1c935cbcbe51002) Approved by: so Approved by: re (implicit) Security: SA-23:16.cap_net Sponsored by: The FreeBSD Foundation --- lib/libcasper/services/cap_net/cap_net.c | 2 +- lib/libcasper/services/cap_net/tests/net_test.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/libcasper/services/cap_net/cap_net.c b/lib/libcasper/services/cap_net/cap_net.c index c6abaa69faf6..ca9434adc6f7 100644 --- a/lib/libcasper/services/cap_net/cap_net.c +++ b/lib/libcasper/services/cap_net/cap_net.c @@ -1234,7 +1234,7 @@ verify_name2addr_newlimits(const nvlist_t *oldlimits, oldfunclimits = NULL; if (oldlimits != NULL) { oldfunclimits = dnvlist_get_nvlist(oldlimits, - LIMIT_NV_ADDR2NAME, NULL); + LIMIT_NV_NAME2ADDR, NULL); } cookie = NULL; diff --git a/lib/libcasper/services/cap_net/tests/net_test.c b/lib/libcasper/services/cap_net/tests/net_test.c index 49cb0da44a4e..34661339340a 100644 --- a/lib/libcasper/services/cap_net/tests/net_test.c +++ b/lib/libcasper/services/cap_net/tests/net_test.c @@ -708,6 +708,18 @@ ATF_TC_BODY(capnet__limits_name2addr_hosts, tc) limit = cap_net_limit_init(capnet, CAPNET_NAME2ADDR); ATF_REQUIRE(cap_net_limit(limit) != 0); + /* Try to extend the limit. */ + limit = cap_net_limit_init(capnet, CAPNET_NAME2ADDR); + ATF_REQUIRE(limit != NULL); + cap_net_limit_name2addr(limit, TEST_DOMAIN_1, NULL); + ATF_REQUIRE(cap_net_limit(limit) != 0); + + limit = cap_net_limit_init(capnet, CAPNET_NAME2ADDR); + ATF_REQUIRE(limit != NULL); + cap_net_limit_name2addr(limit, TEST_DOMAIN_0, NULL); + cap_net_limit_name2addr(limit, TEST_DOMAIN_1, NULL); + ATF_REQUIRE(cap_net_limit(limit) != 0); + cap_close(capnet); }