From nobody Sun Oct 20 15:52:55 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 4XWjdM3pJrz5ZSTR; Sun, 20 Oct 2024 15:52:55 +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 4XWjdM27Dgz47GD; Sun, 20 Oct 2024 15:52:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729439575; 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=LWnAksanBiWcvhEsou7NTaY25WYk/wGcDvV/tQthaZQ=; b=yEtKbEjzTP782XvlgoWBWNJ3CXmF2z4DGn/FfzYVFDbPLkUzNf0/U/YnZILnbzwBSXfsmb 8+75Bw8GpLuLWPZdFXL2l1+8eXjMuoDvkKq08mR+SDGuhwNp1VQTwyNz175OT7YIZk1GQB LWXfcTjrq5bxYmEGJZp0M7Yl2M5rXfJoUiXj8KrC/wcmhgYCYQLA+OUwVDwulQ4Sk9g+xf 8kbypE7UchHnjIiCzfD0/dw6bF8R1+G0bg9p1mQ7ULQjb6PMIyAAkc8Y62RkB9ni1sSixd E2kfnEhJ6gUU1um1qIHn3WKf0FT9pyIDjAo8o0DIlaNl/b2CDE2b7bQ7ZP+Zpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729439575; 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=LWnAksanBiWcvhEsou7NTaY25WYk/wGcDvV/tQthaZQ=; b=bvfUs2QYX09erOQ4yrtbhJhkrhJWvneceQlyteEDg+gs+NxoRbGG/YxDrvK3jMnkkRbruK hZDzAAbCebHnrucds1YnTtgoRfXn7RDw9YFIM5nVGgqTTeIHf7H9n8NJLjK/FWr8buAmzV Dpvmjq3umTt34KrLSH+fITzOUB2Rl81SiNza3LQ1LK5Ug2ctrfBY+QMprFkaivVZiHnoRS gc7GppyyAcM3YFNrVXu86/WBInrahxixWOA4BzI2RorI4NOImX5x+ZRKZA3s0l8eXpt4v+ 2LSpvIYwBCqXbo4ynxy96h3iuPLCXCz++OTqH+O8/bvjGWRbPSCf3y1HywVBlA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729439575; a=rsa-sha256; cv=none; b=DMEsUoK7mImUQwfmgZDpziAJ7SuTrpBhua8rrrk4b9mcOLyz/Iw5ObpK1+5V2IknNaSVES K+3HCNB0TnlR8KmDzUaNpQHlfD+LgsU+2HP/lCKktGAhyM5a8bYYncN3UXTx9xEYYDweuE /u5hU8oz9kZW6FNdwyZAMvdVAGM9d9fmiXPynIWefH1Xj1DOkfmvZSqMPontIhnP37QcVm rkuAzjnBO+17RaCVVGDIX8dw+3F4s3s2OQ6gsozT8mVEqOs5my1FgVuchyYzNUFrzUvZ/Y KwA4AKkK9jGgg81enqw00At9T0M7a7NVIb+oPDxhYlMB4UqGlgOSdAAUZUvT7w== 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 4XWjdM1lFdz16xL; Sun, 20 Oct 2024 15:52:55 +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 49KFqtaN064155; Sun, 20 Oct 2024 15:52:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49KFqta0064152; Sun, 20 Oct 2024 15:52:55 GMT (envelope-from git) Date: Sun, 20 Oct 2024 15:52:55 GMT Message-Id: <202410201552.49KFqta0064152@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: eaab882600d3 - main - Revert "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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: eaab882600d3cf1562a4030e7c91ad3e0861937b Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=eaab882600d3cf1562a4030e7c91ad3e0861937b commit eaab882600d3cf1562a4030e7c91ad3e0861937b Author: Mark Johnston AuthorDate: 2024-10-20 14:27:25 +0000 Commit: Mark Johnston CommitDate: 2024-10-20 15:52:28 +0000 Revert "Reapply "sbin/ping: allow normal users to specify larger packets"" The value of MAXPAYLOAD in the re-applied commit is not right. Back this out until it's had a proper review. This reverts commit b88df1e893c455731c7915f72a3b97b078ab04e2. Requested by: maxim, glebius --- sbin/ping/ping.8 | 3 ++- sbin/ping/ping.c | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sbin/ping/ping.8 b/sbin/ping/ping.8 index 951049d0f252..0eaec196e1e3 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 October 15, 2024 +.Dd September 15, 2023 .Dt PING 8 .Os .Sh NAME @@ -312,6 +312,7 @@ 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 e6b1247af497..d9d544bc75c8 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 ((int)sizeof(struct ip) + MAX_IPOPTLEN) -#define MAXPAYLOAD (IP_MAXPACKET - MAXIPLEN - ICMP_MINLEN) +#define MAXIPLEN (sizeof(struct ip) + MAX_IPOPTLEN) +#define MAXICMPLEN (ICMP_ADVLENMIN + MAX_IPOPTLEN) #define MAXWAIT 10000 /* max ms to wait for response */ #define MAXALARM (60 * 60) /* max seconds for alarm timeout */ #define MAXTOS 255 @@ -458,10 +458,11 @@ ping(int argc, char *const *argv) errx(EX_USAGE, "invalid packet size: `%s'", optarg); datalen = (int)ltmp; - if (datalen > MAXPAYLOAD) { - errx(EX_USAGE, + if (uid != 0 && datalen > DEFDATALEN) { + errno = EPERM; + err(EX_NOPERM, "packet size too large: %d > %u", - datalen, MAXPAYLOAD); + datalen, DEFDATALEN); } break; case 'T': /* multicast TTL */