From nobody Mon Apr 22 15:54:29 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 4VNVDj2WQBz5HMqH; Mon, 22 Apr 2024 15:54:29 +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 4VNVDj1h5qz44Rt; Mon, 22 Apr 2024 15:54:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713801269; 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=qYGTPfmQsaWjJyTs8K5+LL7vDHK1vlOmJD3FHhZYv5M=; b=Uj2woHJARZlB9YEcSnBL/zk+c/eN3uxJXjRZL1lMG/qtTcZVLKyN8Yz6UJnZlZOuesHzam sCj2G2Fh728f8ZW1Ddbzsj4pUwB1iV2FZQvvZOt+wxW3oIjg4y3xV8+PGEqdbgnx/OTwUZ dr1W/xSpnr1u3Zbf/9dcg1tG4vOJe9Xkl7kt5+zTI3jHqqdpm1FFJjsRr/YjXhICLGJW5C iD19ym9LNjoCr3YFdLmCaCBHGl8uwK2ycMNRsReNMR30Z8MpI/f1NhWyxRD+YDZl2iOiPV F9WzMdDpGk+W4y1cJsKNS8Q34VSLPOGHQVFOfgXWfmJ4UiBZN5w6EwdoJlAnsg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713801269; a=rsa-sha256; cv=none; b=EweF7OGJZAsO/Mtz7XU5j86ZN40QDbVHvoLukChxXgwJyTd79dL2NNlFhCoup494hIe6HU 7zkfJfLl+sTHNUExrSk6HK+u1lZxv0adCpkS4LThgp98lPvgtWlqpVOzK9zA8qYNoxMRZz V4WtViHzxGQHzwYG1VoMtXDj5YbxKz+XhvI9RH2D2BO0hzQbHR7P0nyxHoXx18cWFKOvCQ lgsp8XOo+q3+bUZM/R4/8Kct3UqIAuN2YFtd+qdTh/dcyaJCZZS3nEQ5XnaZK0W6HCvo2l X0IeY/hwGP9iPNElKRSwvR+2qTCpLEVlQvtW6Ke7KiHWbp5/pPnY/lIuIP2GIg== 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=1713801269; 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=qYGTPfmQsaWjJyTs8K5+LL7vDHK1vlOmJD3FHhZYv5M=; b=kokvj55cTDeQvgnzjkeb/hIWxEGwl2QtiWfUlGWPNJaSHRJl03RkqplXXZ10uTvVvgApCY JPoYVqCF1kfbOij2Ds+y+SKBKCRt139TDIAJuBTnhUl80HdtJ5XHA0Q8g/I/KFFoAY9Vp6 XPlbNgMZ0FB/6cMsD8y1HVf0BsY+HQLESjRyXir5f3yoKMds11i7jFvbLro70wzXzd5rHA IjkPvE8MdyeJECSDuKao3WukW3CkE5MTO5XuK69vZmmScz3NBIIZWz6CucV/jvcgsT0KYM KeSeHGND6DZT4qHsXXl5F/Iy75J6koHIKDyxnNx0dYFZvW2oRed6kdrncrieyw== 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 4VNVDj1JVzztNj; Mon, 22 Apr 2024 15:54:29 +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 43MFsT2T041273; Mon, 22 Apr 2024 15:54:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43MFsTsg041270; Mon, 22 Apr 2024 15:54:29 GMT (envelope-from git) Date: Mon, 22 Apr 2024 15:54:29 GMT Message-Id: <202404221554.43MFsTsg041270@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 7f7b4926a779 - main - ng_hci: Add sockaddr validation to sendto() 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7f7b4926a779845116913c85ecbb10527daeab02 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=7f7b4926a779845116913c85ecbb10527daeab02 commit 7f7b4926a779845116913c85ecbb10527daeab02 Author: Mark Johnston AuthorDate: 2024-04-22 15:48:00 +0000 Commit: Mark Johnston CommitDate: 2024-04-22 15:48:00 +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 --- 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 5d015b2eac6e..b8caf0c515fd 100644 --- a/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c +++ b/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c @@ -1598,6 +1598,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);