From nobody Wed Oct 16 18:40:08 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 4XTKX870JWz5Yrkq; Wed, 16 Oct 2024 18:40:08 +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 4XTKX865Fxz3xJR; Wed, 16 Oct 2024 18:40:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729104008; 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=5NEF6DoN2QVq3w/b9RhYmW3uSw624M3Itjc6O9Z7tgo=; b=F78EVdoIOMxiWpEef0CAoIbzcuUhlTd320lhm88K7/ExmHZn7U0DaqX9/oggzgsF4S5TSa rbCqa5uqaQIiO24jQs2c0piBlDbEV2prWeS7xTioT9FPTo8AWzcDDQdLqHHKCtTNQiD3F3 egyO6FsiftZuaV/N6mFE2WVi0HSuRvuLXV7eDxd9zLnDpQCrrl5yzOPBoJQStN2wd3YEEX m0X8+9Ty7rr9ssD8UTSUTtTiTrQ+V5GRgJAmqwPl1n0Vv91r2AcNwTv6oYCjaDJy5L4ckO 3QNVdkAK53J7gFJ6joManRFWbRrD/5CR58OApBOMPGO2vowYwVLNVkA/7QMCbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729104008; 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=5NEF6DoN2QVq3w/b9RhYmW3uSw624M3Itjc6O9Z7tgo=; b=qrUf4aTnHVZneVUKbYmApmvt4n/YgBX342dfqbUO3bqxUifJ04FWRQ5Zmfuru25oJavjpI rSz1ElESSkKQRYN+YXZTNKYnbaGk8lNm6SMrgEcI+k2DmYjzsj1fWtqmQN0byqnk+bSwry GT9+706xW5oXizUSqb9dycRQB4V0+MbfygwAKXPFIh3m1YEwnPg6CMPmu2UvwUlrlWjXyU JpYjO3FbUIGQ83aDYWY//AV0PN3jARBobIxZifE2neJJb4+0nc+GQMvHCXjqFvw+YNaQBo T4dMywkCzq3pisn4fG0bA60pmdWqNcQWbbIGYHAjIZwDYryBh0aLEWHJ5LatQw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729104008; a=rsa-sha256; cv=none; b=pDpYFHqnu8W7S7rWmqnCP6UMnCBrJ329SS8g+1rCNFOQBYNVpbay+toguqZifM0Z2LRh1k Ub4dymNgPuUm1WKzEEtUV2y+KHAVnZtw42MnyUoP+W51QIUcUG5EbdN9eJWH6cry8AB798 5Y2+SlNHLkTZc+mUUIxmYMTJZABo1VNC4rIK4XiP+O9QkM8DmPHQ7ba7NorskwYfQTQ9n1 IuIX4u3VMItB/fd99sOOrXttczukwb7U8AsNFEX1mBN/JwSHQLBKyw3DyuUZ9Wgh1itQvF 0bi6x4t4sRjgEetM8bpfgwej1bdQgOzAA2SwJ/eiI2rZma+AzXD0Y5monXxc8Q== 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 4XTKX85hPwzH1s; Wed, 16 Oct 2024 18:40:08 +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 49GIe88R000412; Wed, 16 Oct 2024 18:40:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49GIe8CR000407; Wed, 16 Oct 2024 18:40:08 GMT (envelope-from git) Date: Wed, 16 Oct 2024 18:40:08 GMT Message-Id: <202410161840.49GIe8CR000407@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Pedro F. Giffuni" Subject: git: b88df1e893c4 - main - Reapply "sbin/ping: allow normal users to specify larger packets" 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: pfg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b88df1e893c455731c7915f72a3b97b078ab04e2 Auto-Submitted: auto-generated The branch main has been updated by pfg: URL: https://cgit.FreeBSD.org/src/commit/?id=b88df1e893c455731c7915f72a3b97b078ab04e2 commit b88df1e893c455731c7915f72a3b97b078ab04e2 Author: Pedro F. Giffuni AuthorDate: 2024-10-16 18:35:44 +0000 Commit: Pedro F. Giffuni CommitDate: 2024-10-16 18:39:48 +0000 Reapply "sbin/ping: allow normal users to specify larger packets" The ping tests were originally broken by an unrelated isue that is now fixed ( 2926c2594249f64fecbbdcb0b0b9a3591931ab04 ). THanks to kp@ for fixing the test and Jose Luis Duran for pinting it out. This reverts commit 7bc0cb91a2dfc7e23d96efd0fb7866ee2a23ba88. --- sbin/ping/ping.8 | 3 +-- sbin/ping/ping.c | 11 +++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/sbin/ping/ping.8 b/sbin/ping/ping.8 index 0eaec196e1e3..951049d0f252 100644 --- a/sbin/ping/ping.8 +++ b/sbin/ping/ping.8 @@ -25,7 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd September 15, 2023 +.Dd October 15, 2024 .Dt PING 8 .Os .Sh NAME @@ -312,7 +312,6 @@ with the 8 bytes of ICMP header data. .Pp -For IPv4, only the super-user may specify values more than default. This option cannot be used with ping sweeps. .Pp For IPv6, you may need to specify diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index d9d544bc75c8..e6b1247af497 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -96,8 +96,8 @@ #define DEFDATALEN 56 /* default data length */ #define FLOOD_BACKOFF 20000 /* usecs to back off if F_FLOOD mode */ /* runs out of buffer space */ -#define MAXIPLEN (sizeof(struct ip) + MAX_IPOPTLEN) -#define MAXICMPLEN (ICMP_ADVLENMIN + MAX_IPOPTLEN) +#define MAXIPLEN ((int)sizeof(struct ip) + MAX_IPOPTLEN) +#define MAXPAYLOAD (IP_MAXPACKET - MAXIPLEN - ICMP_MINLEN) #define MAXWAIT 10000 /* max ms to wait for response */ #define MAXALARM (60 * 60) /* max seconds for alarm timeout */ #define MAXTOS 255 @@ -458,11 +458,10 @@ ping(int argc, char *const *argv) errx(EX_USAGE, "invalid packet size: `%s'", optarg); datalen = (int)ltmp; - if (uid != 0 && datalen > DEFDATALEN) { - errno = EPERM; - err(EX_NOPERM, + if (datalen > MAXPAYLOAD) { + errx(EX_USAGE, "packet size too large: %d > %u", - datalen, DEFDATALEN); + datalen, MAXPAYLOAD); } break; case 'T': /* multicast TTL */