From nobody Sat Oct 19 12:56: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 4XW1mF5gd1z5b4PD; Sat, 19 Oct 2024 12:56: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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XW1mF41tFz4Nh9; Sat, 19 Oct 2024 12:56:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729342589; 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=jNGV2sTalawTWg5+zmgQ/emLsTKCLnZJ0GeDqOwoEBY=; b=QV4yR+8LqcQdAHP34I2hnh6WqvxX2EPyKJdZWNTd9dFuUAF3OtbmaZEsdrauGJJTtq19l+ ypEFVZrZxnkb1GXWhEOh6k2jitWt8g44C7zRoNgoqI2CmIFP61M9nGtGKLPcwqUT/qK5Gf lFIWCDGH5FQBgyftF7H8pEd19Z+KA4+9Kfb/XaSaYgT8bYnq9UmK5T1BaChFDG3m4+eUw+ sXjDFJUHLgDY1NxQ3R95J1+w1wPkyHsc9Rfj+a8pXoS0m1n+eBEwdQPkugyC/LhEpvwFl7 mVRxeYKAzSsm/xChMgfxeDs21hxEQWVLYlsauu+dOAm4jJ6zd6cBQTXztiVQdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729342589; 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=jNGV2sTalawTWg5+zmgQ/emLsTKCLnZJ0GeDqOwoEBY=; b=wqi5Mqo99MG7XVDZICfzSaPRksD2uzliVWAcrn5OKTbsHrqHfHCKtmrjovwgy4sj2X/P/z zwTuxkrnSTL/+vNRRE4CahH/OQ/OSbzmhhVq4MXbvSldCks9ou1uazQxfi2uxA9g+i9VkQ ZD54ExbH/jYvEbRbcyMOYClNFODBHJcjC7ya2auX5TensB0160lYDTrg6yxJyJJknXoyi/ uYgQrgnCmYqSfPSgAp/1M6ZBXYlJa1kFThiHkkeYCCBcGvDZKWoY+fLI8XHLrTSalS2V+i c/pgG/dO1X93MLM//FSjM3Esa8fNqGz37dPvO/pZ6noNg9vuDaEbD2yubnmmpw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729342589; a=rsa-sha256; cv=none; b=EIFtkRLcSm1n4/Ec6yoIzNn0ch3RD0IFoT2O7bD1EM/cEwBL8VLMRnVcotZGDczF0saY/t rDViToGq2AQk+wKWNDJZW+FWvOuEopmAxAv5OAMsxZCyrsNtbdtov4eAOIMBypOf7xOBNp L2W8q5d5MubbuGKO2UGoh9WT4RTXjfh8pASpzXTItj7st6/maR4/9D/erNYP4+/5rfPWu9 uSwj9CKjoNqHe3fVRuKn/qtw3FtmCWriTM+jgpF+MJr3vniU1AYvziYinPg5aYrZAhMp8u 9bsN02kjI4fCBmTQkWCKBQr/GqYT4LCpejWIUWoENNOpl+RFGfoGUeIeQYbIvw== 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 4XW1mF3KQ4zJfp; Sat, 19 Oct 2024 12:56:29 +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 49JCuTgq065069; Sat, 19 Oct 2024 12:56:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49JCuTlJ065066; Sat, 19 Oct 2024 12:56:29 GMT (envelope-from git) Date: Sat, 19 Oct 2024 12:56:29 GMT Message-Id: <202410191256.49JCuTlJ065066@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: 4e61f158893b - stable/14 - debugnet: Use precise types when accessing mbuf contents 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 4e61f158893b4fcd95a93ccee3812e395378feef Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4e61f158893b4fcd95a93ccee3812e395378feef commit 4e61f158893b4fcd95a93ccee3812e395378feef Author: Mark Johnston AuthorDate: 2024-10-09 15:28:57 +0000 Commit: Mark Johnston CommitDate: 2024-10-18 12:28:09 +0000 debugnet: Use precise types when accessing mbuf contents This might be useful when adding bounds checks to mtod(). No functional change intended. MFC after: 1 week (cherry picked from commit 5c385a54fe9ccbd3f28f20b5a025a856d229fa05) --- sys/net/debugnet.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/net/debugnet.c b/sys/net/debugnet.c index c6f57ec84618..07906e724cbb 100644 --- a/sys/net/debugnet.c +++ b/sys/net/debugnet.c @@ -199,7 +199,7 @@ debugnet_udp_output(struct debugnet_pcb *pcb, struct mbuf *m) return (ENOBUFS); } - udp = mtod(m, void *); + udp = mtod(m, struct udphdr *); udp->uh_ulen = htons(m->m_pkthdr.len); /* Use this src port so that the server can connect() the socket */ udp->uh_sport = htons(pcb->dp_client_port); @@ -226,7 +226,7 @@ debugnet_ack_output(struct debugnet_pcb *pcb, uint32_t seqno /* net endian */) m->m_len = sizeof(*dn_ack); m->m_pkthdr.len = sizeof(*dn_ack); MH_ALIGN(m, sizeof(*dn_ack)); - dn_ack = mtod(m, void *); + dn_ack = mtod(m, struct debugnet_ack *); dn_ack->da_seqno = seqno; return (debugnet_udp_output(pcb, m)); @@ -400,7 +400,7 @@ debugnet_handle_rx_msg(struct debugnet_pcb *pcb, struct mbuf **mb) } } - dnh = mtod(m, const void *); + dnh = mtod(m, const struct debugnet_msg_hdr *); if (ntohl(dnh->mh_len) + sizeof(*dnh) > m->m_pkthdr.len) { DNETDEBUG("Dropping short packet.\n"); return; @@ -459,7 +459,7 @@ debugnet_handle_ack(struct debugnet_pcb *pcb, struct mbuf **mb, uint16_t sport) return; } } - dn_ack = mtod(m, const void *); + dn_ack = mtod(m, const struct debugnet_ack *); /* Debugnet processing. */ /* @@ -503,7 +503,7 @@ debugnet_handle_udp(struct debugnet_pcb *pcb, struct mbuf **mb) return; } } - udp = mtod(m, const void *); + udp = mtod(m, const struct udphdr *); /* We expect to receive UDP packets on the configured client port. */ if (ntohs(udp->uh_dport) != pcb->dp_client_port) {