From nobody Mon Apr 29 14:13:14 2024 X-Original-To: dev-commits-src-branches@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 4VSlfg0nbZz5JQcm; Mon, 29 Apr 2024 14:13:15 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VSlff6xXNz4Fgg; Mon, 29 Apr 2024 14:13:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714399995; 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=5x+8VcbNGFyboG6qQonGbXfeLMuZoKOEzANG3cBwxNU=; b=EzJJlqIpT4dMA3RWh4gF+56MWzpn+QlWiSXucn4us8SZeYC1SvZnQVBySi/+LpzRkLy5l5 sV5u0tMOnIyWExw82NnojlRKEDcQ2syJXNHsRRq5mF57etuY+4Qc7zrbDD/kNaIAfJZwo+ H8oCmvX71PpIK4o0jhh+/cSpzim6avMBFIIRN325MOv3miTj0SRjI5Ot/265zLKt/c/utD Qs7kImakix5FGE+y4CVmMcahu0QNK9ELR4M7kjSaUEWDXGEoCVS1SlbfqaOOOKHRK523EU lS/IdztFzQLXUAcB/aMWSlDMi/yIvw3rBdsJEb63KQSm0i7fuVfMwZfqk/rS3g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714399995; a=rsa-sha256; cv=none; b=EtMlDwrJf2nyj8c5GhHWtr7ZWhzoHY/TIHorDVpKJQd2PXtnBSFiGiGua/o/M5eJAgncVI fEUWFPWTvKiUaT7JByGBfbTL23g9f0YPekFfiK+bc4/eWr1VrzmVsOM93ZCgsfofdUH9dg kthHs+6FmHYsBBA19UgWjBWADumDw4erubbCj4iWIJz4/h5TKT31C4NI8v/aotNax2tcT8 A+50oF76aWFeDYJyrCNWwKyeQTn+cT9Uh+I3fXXbi4xW80801pXVSf32uN5OTjOy8Jq/BP YDMEsyBa3LEhcOF7fFtUMPnWKGF8N6LBVaWdO0cBjLBMTadz6YnhBy4vdIvGog== 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=1714399995; 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=5x+8VcbNGFyboG6qQonGbXfeLMuZoKOEzANG3cBwxNU=; b=eQF1u8d6irYmlBOyqAoZIA/PlMhYrfPzcvCzZvXmDLDqqYEhvDUPledvpKapmmvju0Bi6A kRJ0uaNd9H96uBVk/aJbqViXkLXUUoEyBcvHnKvagiIwOV6SryywfEj5CEx0g2UfqZ/2if hKq90Ee/wjgFOT3urvMt1eShHP8QPGaRyyh0Xg/5fBIwDDFEDA4re5mVdqovBebQ3gYRMl Qvk2jrPI5bLyj3rA5iVBvs6LvEfFNixj/UwsJ46Z6vYZ8QMiqtUAjx+AntjyLOobMHuHuM jW2fI5PLxrCwAyolK616YnJEw01kz+Ae4Rtx9oosKiIGUb3U/2gQ3k3YxYvufQ== 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 4VSlff6Vr7z1Bj0; Mon, 29 Apr 2024 14:13:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43TEDEC8046157; Mon, 29 Apr 2024 14:13:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43TEDEpN046154; Mon, 29 Apr 2024 14:13:14 GMT (envelope-from git) Date: Mon, 29 Apr 2024 14:13:14 GMT Message-Id: <202404291413.43TEDEpN046154@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 6f028e91084b - stable/13 - ng_hci: Add sockaddr validation to sendto() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6f028e91084bfedb9a5ca99c857a9c30a094beb5 Auto-Submitted: auto-generated The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=6f028e91084bfedb9a5ca99c857a9c30a094beb5 commit 6f028e91084bfedb9a5ca99c857a9c30a094beb5 Author: Mark Johnston AuthorDate: 2024-04-22 15:48:00 +0000 Commit: Mark Johnston CommitDate: 2024-04-29 14:05:34 +0000 ng_hci: Add sockaddr validation to sendto() ng_btsocket_hci_raw_send() wasn't verifying that the destination address specified by sendto() is large enough to fill a struct sockaddr_hci. Thus, when copying the socket address into an mbuf, ng_btsocket_hci_raw_send() may read past the end of the input sockaddr while copying. In practice this is effectively harmless since ng_btsocket_hci_raw_output() only uses the address to identify a netgraph node. Reported by: Oliver Sieber MFC after: 1 week Sponsored by: The FreeBSD Foundation (cherry picked from commit 7f7b4926a779845116913c85ecbb10527daeab02) --- sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c b/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c index d4a447f4254f..de25f5369ffa 100644 --- a/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c +++ b/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c @@ -1610,6 +1610,17 @@ ng_btsocket_hci_raw_send(struct socket *so, int flags, struct mbuf *m, goto drop; } + if (sa != NULL) { + if (sa->sa_family != AF_BLUETOOTH) { + error = EAFNOSUPPORT; + goto drop; + } + if (sa->sa_len != sizeof(struct sockaddr_hci)) { + error = EINVAL; + goto drop; + } + } + mtx_lock(&pcb->pcb_mtx); error = ng_btsocket_hci_raw_filter(pcb, m, 0);