From nobody Fri Oct 11 13:23:52 2024 X-Original-To: dev-commits-src-main@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 4XQ6lX5cxwz5YsKY; Fri, 11 Oct 2024 13:23:52 +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 4XQ6lX4nBMz4b0h; Fri, 11 Oct 2024 13:23:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728653032; 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=kvce2cB25UMvr0IzP8JRs6FEbma1iR1AO/yL8zATcK0=; b=cc6TWdAE+7LRyKL8xA6X5v1w1g8pfbEE5fwN30CLjoR+wNFEfWn/2VvBWmTu9sDiR/8GWv kbqEPUk5BmbaHouflqCGE/MdVOEC/zZRri2SDRutrEZp3znOOxDwQcNxJ5n0CiEx4BEDbX HHMch0Fb3DeJilAeeBojH5K254iqgzuXJhhxaw0EDjjijXJVcSzMDF8cS3WimBS0yenmvS t8u2JXSBaqjy4pLCuYDxUQTXv97FXsNcxpyjvJSIJ4/RkO3LdWd+DnQ2W0l6NPfExxwZhQ I9B0E/vz7/QjSMAa0XfgmjNgRtRc4GTPmDAGWo70lQ/abnXxlHfp3R+J2Y4P+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728653032; 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=kvce2cB25UMvr0IzP8JRs6FEbma1iR1AO/yL8zATcK0=; b=pc7xgIJ8gQgKek5C4D14ziDgAe2AW4EPkj5v/IcXylV9AevlFRpTCjdQ04kfQ+QSi/n6AR FT8dn7zMTSUoINhxKP4ioUBox/RqQuXfrk/Vy9VDUwMRJ7P87Dhwd09t7uWLgytXpDps0T j9UFtr5e9okHF5rEt+iwyTdSBJLawqqJqlCKuDDmgLwBIUCaH3xOBpP9IMOzlRNc3V0Vms cJt6u6CJfkBsnxJ9uxTdmGLbQO3H8gXCEF7sU4n1f5A4uvQ5LidjtBiGOj5hWxxYnvSymS MnwKnlzAWsreaNkLQdiU/WXzjGBXsMNegIoHkVA2EIDE8xrmTfdnsUGKHAuhlg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728653032; a=rsa-sha256; cv=none; b=S4N+pv6kKjHLH52XlFsotX1Oj476xFxhfTttaklE/HH3x4qubAGDGrY90cpK+AAEEzlWjr NtzmfYdRucfVmb5LftTiZ3E44X5mB5PvKqpfCYWXAQphWM2jTPHZvxGDY6hULMsUbVUq/v J1wbTKUG6XxKk2hf0OmHD+4FWKNWebRDHeELtZwVfzhW6+k/L3h8AQV9pP5DAs6B2ZEWEC i/PjZ6792NVZyoUuqUpVaJ+O2EGq1Zo2nCZWwCRVqbU4QjSJcMeMrZ1E2LQQphXoIyXfB0 4Z/WkZ9X9j1MfYx6LOSDnH3KQuhRgLNm+NGNAz/uZWjahzOChjf+t8VCEzLj6A== 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 4XQ6lX4NMXzjvm; Fri, 11 Oct 2024 13:23:52 +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 49BDNqmN034196; Fri, 11 Oct 2024 13:23:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49BDNqJ7034193; Fri, 11 Oct 2024 13:23:52 GMT (envelope-from git) Date: Fri, 11 Oct 2024 13:23:52 GMT Message-Id: <202410111323.49BDNqJ7034193@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: 5c385a54fe9c - main - debugnet: Use precise types when accessing mbuf contents List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: 5c385a54fe9ccbd3f28f20b5a025a856d229fa05 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=5c385a54fe9ccbd3f28f20b5a025a856d229fa05 commit 5c385a54fe9ccbd3f28f20b5a025a856d229fa05 Author: Mark Johnston AuthorDate: 2024-10-09 15:28:57 +0000 Commit: Mark Johnston CommitDate: 2024-10-11 13:23:25 +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 --- 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 8b1419bcaa28..32a91256f51d 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) {