From nobody Mon Jul 22 14:22:38 2024 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 4WSMtk4clRz5R1lr; Mon, 22 Jul 2024 14:22:38 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WSMtk3mDyz553n; Mon, 22 Jul 2024 14:22:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721658158; 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=/3fVgOBOrpLk9FoMqH8Xt8gJpv0l8DTx7v+g+14cwEY=; b=NMH0XQusK++s2qUwTuVt8ch/r/pcLdK4ER3Jt6dGID8iTvX/mOvUgTTDDGb8loKt9n3u2J licPZLOytff0V0UvvtqwHFKMQsnQ3z+RZcAZ2eTdzMYVcIjRac0PAGIhXFD0NZ/oorIheT axKacjaTKjdCNC9UkARQ+xp+tt9M4bBpSLkg496tGogaHAwqJtMlNEPE16ei1tiC/3qnyN 9+EAem548fz7NdqnPL4KFxFqF/unHSdmYRYIN0uuKV/0L+zOl99NJAvxfyYdG4gb8Oqtzq txuvkLMtHmkZyjQRWayPATXPdWwxin5pMvrM8BkrJ9sP/ZIZdK5zSu/0GkAyYw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721658158; a=rsa-sha256; cv=none; b=QASh01Cgykwucq9oVsVQaQdQ/89yJkZWkCXDcMIA8eeO0gl7gp461VV2OgaXABNVe0BzKx gCh/ygoKqx3JjehhfXoyELYgi99BwuWn3S5qe5rySfrv+uzN0gfJ7+PY3Vt9X+NZPcgGGh nq6n3MKt2OIK8hhcnwq2wTC3rZ4QsK6nEtOzCVp7HjM4Q8d6zdSSyz0KtjcWYYWp+qD65I JkhA31vD8rg2hUaHZi/VI13k8HKihCHSgb7LriCRJ58/eh+/CjnZQApg3JNX02JfO78htk KOx6rK8+DhdO6ittQLfnTjSxGGEMy2uZ83PBgCuhEEKhIY1zYsVs0TWw4/zX7Q== 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=1721658158; 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=/3fVgOBOrpLk9FoMqH8Xt8gJpv0l8DTx7v+g+14cwEY=; b=q28FUSuverIyvlnYzTDgygLsOwXi5n45G9YtV+TA6d4Wg8+A6t+7OmNbKSWThbtrDiFb2H ddh0g0xUXkv/OzanXsKmkrmaU9pSKZlFUthJGCPNkoqI68BVYpb6FCSLGVnDQwT7fKfK0U rtQ9XbHu+9A4Pi+KeM2EaLCZRSkItRcwmlfDKSfzOo0ecA7ER8mpddhRy1JLyWPlLQWPMH MYzOZqSmv2ar3rRj/M0us8eVAbokk780deyki7BqZByLKYP5nZ3TjvAuMgPQzpK3ZgEWBW OusFb2YsNoPQTjW09zU797Z7zL36I0Lq+cTyCuPu+HHWxVSupCYWLqxRFhkdNQ== 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 4WSMtk3LMzznqv; Mon, 22 Jul 2024 14:22:38 +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 46MEMcAv081948; Mon, 22 Jul 2024 14:22:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46MEMcFf081945; Mon, 22 Jul 2024 14:22:38 GMT (envelope-from git) Date: Mon, 22 Jul 2024 14:22:38 GMT Message-Id: <202407221422.46MEMcFf081945@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konrad Witaszczyk Subject: git: bc06c51419b3 - main - netinet: correct SIOCDIFADDR{,_IN6} calls to use {,in6_}ifreq 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: def X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bc06c51419b338c3d6efa6543308f9905c12c79b Auto-Submitted: auto-generated The branch main has been updated by def: URL: https://cgit.FreeBSD.org/src/commit/?id=bc06c51419b338c3d6efa6543308f9905c12c79b commit bc06c51419b338c3d6efa6543308f9905c12c79b Author: Konrad Witaszczyk AuthorDate: 2024-06-27 12:54:14 +0000 Commit: Konrad Witaszczyk CommitDate: 2024-07-22 14:17:21 +0000 netinet: correct SIOCDIFADDR{,_IN6} calls to use {,in6_}ifreq The SIOCDIFADDR{,_IN6} ioctls take an ifreq structure object, not an ifaliasreq/in_aliasreq/in6_aliasreq structure object, as their argument. As opposed to ifaliasreq/in_aliasreq/in6_aliasreq used by SIOCAIFADDR{,_IN6}, the ifreq/in6_ifreq structures used by the SIOCDIFADDR{,_IN6} ioctls do not include a separate field for a broadcast address and other values required to add an address to a network interface with SIOCAIFADDR{,_IN6}. Whilst this issue is not specific to CHERI-extended architectures, it was first observed on CheriBSD running on Arm Morello. For example, incorrect calls using the in6_aliasreq object result in CHERI capability violations. A pointer to the ifra_addr field in in6_aliasreq cast to the ifru_addr union member of in6_ifreq results in bounds being set to the union's larger size. Such bounds exceed the bounds of of in6_aliasreq object and the bounds-setting instruction clears a tag of the object's capability. Reviewed by: brooks, kp, oshogbo Accepted by: oshogbo (mentor) Reported by: CHERI Obtained from: CheriBSD Differential Revision: https://reviews.freebsd.org/D46016 --- sys/net/if.c | 6 ++---- sys/netinet/in.c | 6 ++---- sys/netlink/route/iface.c | 6 +++--- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 604a93aa7cba..c71643a41bc5 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1037,12 +1037,10 @@ if_purgeaddrs(struct ifnet *ifp) #ifdef INET /* XXX: Ugly!! ad hoc just for INET */ if (ifa->ifa_addr->sa_family == AF_INET) { - struct ifaliasreq ifr; + struct ifreq ifr; bzero(&ifr, sizeof(ifr)); - ifr.ifra_addr = *ifa->ifa_addr; - if (ifa->ifa_dstaddr) - ifr.ifra_broadaddr = *ifa->ifa_dstaddr; + ifr.ifr_addr = *ifa->ifa_addr; if (in_control(NULL, SIOCDIFADDR, (caddr_t)&ifr, ifp, NULL) == 0) continue; diff --git a/sys/netinet/in.c b/sys/netinet/in.c index cc2f37863ea1..c78f0f5758f7 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1222,7 +1222,7 @@ in_ifscrub_all(void) { struct ifnet *ifp; struct ifaddr *ifa, *nifa; - struct ifaliasreq ifr; + struct ifreq ifr; IFNET_RLOCK(); CK_STAILQ_FOREACH(ifp, &V_ifnet, if_link) { @@ -1237,9 +1237,7 @@ in_ifscrub_all(void) * cleanly remove addresses and everything attached. */ bzero(&ifr, sizeof(ifr)); - ifr.ifra_addr = *ifa->ifa_addr; - if (ifa->ifa_dstaddr) - ifr.ifra_broadaddr = *ifa->ifa_dstaddr; + ifr.ifr_addr = *ifa->ifa_addr; (void)in_control(NULL, SIOCDIFADDR, (caddr_t)&ifr, ifp, NULL); } diff --git a/sys/netlink/route/iface.c b/sys/netlink/route/iface.c index 81db54ab12d4..7d33c89a396a 100644 --- a/sys/netlink/route/iface.c +++ b/sys/netlink/route/iface.c @@ -1194,17 +1194,17 @@ static int handle_deladdr_inet(struct nlmsghdr *hdr, struct nl_parsed_ifa *attrs, if_t ifp, struct nlpcb *nlp, struct nl_pstate *npt) { - struct sockaddr_in *addr = (struct sockaddr_in *)attrs->ifa_local; + struct sockaddr *addr = attrs->ifa_local; if (addr == NULL) - addr = (struct sockaddr_in *)attrs->ifa_address; + addr = attrs->ifa_address; if (addr == NULL) { nlmsg_report_err_msg(npt, "empty IFA_ADDRESS/IFA_LOCAL"); return (EINVAL); } - struct ifreq req = { .ifr_addr = *(struct sockaddr *)addr }; + struct ifreq req = { .ifr_addr = *addr }; return (in_control_ioctl(SIOCDIFADDR, &req, ifp, nlp_get_cred(nlp))); }