From nobody Thu Sep 17 00:37:13 2026 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 4hlcKC11Vnz6sYr3 for ; Thu, 17 Sep 2026 00:37:19 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hlcKC04C6z4S3k for ; Thu, 17 Sep 2026 00:37:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789605439; 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=MvBdNxcZWf72Qtwuh49SE1C1SW9dZTihKkM4lFB7kaE=; b=KD/9nd8J3d0rwZaJl0jSuw3pa1Kvol/2wZyix6XrRzrsIqV8+hYIOpsBIPPMXaBcrihTPJ 7DptauuO6uqAYiYAQKFwze1OWSC2SL0Hs9gYsPl9BJFIqWCIlgg+KMSkCkfeyC7C9J7SFn ftttpRW0OvqMwtvcBxzN49RcbX9rgN+3Fkb6rEwjGPS4+iYMF1ADATna1u0v+YstiiepSc VPt3U1/oRYJVAKLautYj2mbNP5BjxKWRbR85lJ2yhu/JHFdT6q8UGOPztgl5i9qOcxBu/W 6GNuJmGhIEZXmVZyTE0GpxKw9HDh9Em/+VoQOgy5q2vuNro7eawEW0NN+44y7A== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1789605439; b=EjkVZBpPu8LWWXTFZA9gwEN4i+dtFTuJCCmGJ4yDtZgeIPjSKf143UZ7jxEwSVJUip4omp AP4Jg8KVimS0zxB4jqnPMZHt5kb7xX5LCMTOCH8d1FsO1/uCZaGGnvCcnmBHKdUDruchz6 JlLzuXX5vb82URkD7l7Z9KZPJb8sTNpdcmKp+eDndzajaJWL0fXGA4EqlIXGBJuIDaac67 /veltYzrtlY8tH7bhxcAxz7315vEcCeRwDK2Txwk8PW5WkkDKlkty+tYRF9ubaJAOItqOM RQIQ268qTp/gJDmDz6ww9KCAnpcekdh9sCK3fSxOPuwQUR6LvbMiAbpFv12vHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789605439; 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=MvBdNxcZWf72Qtwuh49SE1C1SW9dZTihKkM4lFB7kaE=; b=k1R4UarTrtLXf5Q1D0gH+jr25JzUqhKH9b3W2ynmGRc0jiCbkfvGWkei3pSunMnIYU+DGU NeWX++dewVSigVWX/ISlxjd5aoOAeBCJ1s94qGvOaXIaOE08gunSpkHTw7ySNK7QM3J1Vd F9RWeuFbInO+zPKOzaWxuboeKbULjArPq62CPt+qXi6u7a1SnPnJtamYZuoHG0tbvCutXf 5VnZPHW1ZpDbEaF0rHA7HxL5PYxD+VnubIzljPOMqtkwDlmKVttQEonefbcRCdOymJQItb FoU2aIq40O3EjUWTvquL9ZrJs6hRNX114Ny/CtDceixVLXwNIkplIdO7Kg31dw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hlcKB6C8Yz1851 for ; Thu, 17 Sep 2026 00:37:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 277f0 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 17 Sep 2026 00:37:13 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Maxim Konovalov Subject: git: aa6683207d18 - main - ping: do a better job checking what we receive from the net 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 List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: maxim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: aa6683207d189a0b58ccf8806bd9f8793914bc45 Auto-Submitted: auto-generated Date: Thu, 17 Sep 2026 00:37:13 +0000 Message-Id: <6aab3639.277f0.4496dc33@gitrepo.freebsd.org> The branch main has been updated by maxim: URL: https://cgit.FreeBSD.org/src/commit/?id=aa6683207d189a0b58ccf8806bd9f8793914bc45 commit aa6683207d189a0b58ccf8806bd9f8793914bc45 Author: Maxim Konovalov AuthorDate: 2026-09-16 20:33:18 +0000 Commit: Maxim Konovalov CommitDate: 2026-09-17 00:31:09 +0000 ping: do a better job checking what we receive from the net - zero out a buffer for the incoming icmp message that we are about to parse - for ICMP_MASKREPLY and ICMP_TSTAMPREPLY responses check their length and warn and reject them if they are truncated Without these checks a part of stack allocated struct icmp icp could be printed out which seems low severity since we already dropped root privileges by the time icp is allocated. Reviewed by: glebius MFC after: 1 month Found with: Claude Code Sonnet 5 Differential Revision: https://reviews.freebsd.org/D59555 --- sbin/ping/ping.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 362264ff2428..5926641a4a50 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1119,6 +1119,7 @@ pr_pack(char *buf, ssize_t cc, struct sockaddr_in *from, struct timespec *tv) struct icmp oicmp; const u_char *oicmp_raw; + bzero(&icp, sizeof(icp)); /* * Get size of IP header of the received packet. * The header length is contained in the lower four bits of the first @@ -1158,6 +1159,20 @@ pr_pack(char *buf, ssize_t cc, struct sockaddr_in *from, struct timespec *tv) if (icp.icmp_type == icmp_type_rsp) { if (icp.icmp_id != ident) return; /* 'Twas not our ECHO */ + if (icmp_type_rsp == ICMP_MASKREPLY && + cc < (ssize_t)(ICMP_MINLEN + MASK_LEN)) { + if (options & F_VERBOSE) + warnx("truncated mask reply (%zd bytes) from %s", + cc, inet_ntoa(from->sin_addr)); + return; + } + if (icmp_type_rsp == ICMP_TSTAMPREPLY && + cc < (ssize_t)(ICMP_MINLEN + TS_LEN)) { + if (options & F_VERBOSE) + warnx("truncated timestamp reply (%zd bytes) from %s", + cc, inet_ntoa(from->sin_addr)); + return; + } ++nreceived; triptime = 0.0; if (timing) {