From nobody Wed Oct 16 01:06:52 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 4XSt8s1GmPz5ZGN0; Wed, 16 Oct 2024 01:06:53 +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 4XSt8s0glmz4CtT; Wed, 16 Oct 2024 01:06:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729040813; 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=b28/A/jFirZ7OOhzxFnKZBhYhx6w8nEZvURs4XDMkno=; b=iUBkvitlgw0dxJPFWXv/5UShg4OKPhMTWHkBrnrHtmFxlQYYQjiMoWqHkB8N4IkjnBJi8q vt7oa2Z0rxQWfxuKHxcknt/6jwY7duSgnqGBjxWPC+XePlIXjnS/8l5rbHIuap3RWfy5XQ X5+hM9oioY+Q+dCulDzroII66YFL9wJSZKD1b5HRcVqiVQqI59BKlWlQjSqRS1JuIwQ1uO NsAL54xQ3ZBihu/DCPw+j/OdDcJIpVYe8gkkGJei5+SOGwb9+lldn5CNQpKXu4gQbGA/y7 rk23jPVeKHkIoa7JXeXfimCh51vV4AR2tfahdhui4NVvrNxNuSDbYKCL+ylTSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729040813; 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=b28/A/jFirZ7OOhzxFnKZBhYhx6w8nEZvURs4XDMkno=; b=RE2QnQb3viWqBgVEdp38bFfcCiAJ7bLfBTKV5Y+geWdm7dDsdE0O6rWHXppEmnijaO48tr 0W48+aWWIXkhKkPsEtPqKL1teYRlNOfQPCbJ0t1B8rjcbSWZ2FC3fYi2iESEt2V/80lxbj w5Hut1G/3XTyX8ARGzxXjLHAI4xrEzkAdCsEV9X1kFvInmGVX5xOFboSdjdcQCydrfPeB9 /W5PqFo5iHPmGaW5W6BO23Bd65qGB1XuBcuWkkqzGCXj2zg57tpYEwdPujZtpZeGvtdkhF n3nFNBwr1IDCr6Dja01V5Z0u/6++Zl+r9nRB60/dghZEcCFXyXakuZpmIAzfXA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729040813; a=rsa-sha256; cv=none; b=hbwzmPA3TYH0yJvBZFYkLtbZLIZ57Ey2P+l2m48e3X2qtyPKlJ6n0W/tT2lBtF/7gN0y5x F8csAzURDNRD6/Vj/FiiqXOujPZzZ4ZZ2PWI9Km1V9pCs7Ib5ObKOJrL2dRjPQCaXNqxo3 +08+DmgnKa1wOJ8cojXYRF9mzc7+R2Fj0ScOmLgSbD4sBdccxo+7sVqHDh0aZUUgZ6f+oX luAGJGOyyQBotAS+Z+j+vEirEo/veG4MRe62K5+EpPjdXL3wPvtJeyDZpzKyFss5xgIDia zchhC+r0ndX+ApC/B3DHBDfC6575MWetZtPBsZ3CG50kZrTlDyFgsrFRqeTUYw== 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 4XSt8s0H0GzlYD; Wed, 16 Oct 2024 01:06:53 +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 49G16qpn012342; Wed, 16 Oct 2024 01:06:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49G16qS7012339; Wed, 16 Oct 2024 01:06:52 GMT (envelope-from git) Date: Wed, 16 Oct 2024 01:06:52 GMT Message-Id: <202410160106.49G16qS7012339@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: 80a5b26871e9 - main - sbin/ping: allow normal users to specify larger packets 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: pfg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 80a5b26871e90a0ad99d95bd129343471a7a36e3 Auto-Submitted: auto-generated The branch main has been updated by pfg: URL: https://cgit.FreeBSD.org/src/commit/?id=80a5b26871e90a0ad99d95bd129343471a7a36e3 commit 80a5b26871e90a0ad99d95bd129343471a7a36e3 Author: Pedro F. Giffuni AuthorDate: 2024-10-15 20:50:04 +0000 Commit: Pedro F. Giffuni CommitDate: 2024-10-16 01:05:50 +0000 sbin/ping: allow normal users to specify larger packets Only super-user could specify a packet size larger than the default 56 bytes. This restriction was added by Matt Dillon in 1998 during the BEST days [0]. This restriction doesn't exist in ping IPV6 or on NetBSD, OpenBSD and Linux. UMS [1] uses this feature to estimate the client's bandwidth to optimize the streaming experience. [0] DFGit 526f06b278d9252add168aa18b60242c08771165 [1] UMS: https://github.com/UniversalMediaServer/UniversalMediaServer Obtained from: DragonFlyBSD Differential Revision: https://reviews.freebsd.org/D45774 --- 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 */