From nobody Fri Jan 06 17:56:43 2023 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 4NpWHb2TL3z2p4jd; Fri, 6 Jan 2023 17:56:43 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NpWHb23ppz3HlX; Fri, 6 Jan 2023 17:56:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673027803; 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=7aoEwFqhsPQQBDJ09G4r5CnOAVF+UOTAdIseNpRc3Q0=; b=EH0+Tol2YLebQeA5u/Szxb5Q6bMawdazKRF1V5I7YoJqSM/IrzHlHVGAKSvgVnC5EOBNH5 Lqh/yN5JcnPj2YIfSpNhrRNs+4vWgubAIElCrGMxjIF2SQQnmZiU9P2Jxa5kLotT62kx0g 67OO1u5lzCnD/uviMHNNos4H94+o/MSfF5Dl/NZKeYtMsHezunfqXY8B8OEWYF8PlHF1p4 /sZVs3J8mqkqd8ORW3T18zccPfF2goJn4zDuAcIFxlPnEEkyIwzn/gfBVEKIwxKggdGn53 YjTxU8Q0TN+A7C3aulRkkLx5Urea0J1fBro498r8v+Izb5QemRdDlHfbuphpEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673027803; 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=7aoEwFqhsPQQBDJ09G4r5CnOAVF+UOTAdIseNpRc3Q0=; b=Z8S7SsXQ0aXKdJWeIi0JN44q6EteQU0E7pIIPKkGdSoLalMqMJpU1sv9goi9rtoPrXzzU6 rxcrvz4DT7jnbswVx5V/gO6nqg9Uk2taY8mJlxdgkJW6bv/+0ROoVa7kWM0aeExGx4PeF8 1njeysC44L8n4fqXXFm65x8wNm0Dc0YyWVNgQWh45hEclXF4IEQ4i+UWmux8EXF0wxgWhh 4dPIUrhDKwS5CJLVYZqRW1deo82O0V9n6crhOXstaBsrNwrI7lK75AEJRdvcWtC0XDmbbo Y8/yoYopCU55w7E0FQBetNtTRFmCKizFWs/enr8FBr8wpHo18vRFbtmjJbT7Xg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673027803; a=rsa-sha256; cv=none; b=AJv7SUbXhupcO7QodibrPp89cQDg2E8BG6o7+R4zNDamMoxQASrwpqPUG/q+kE8/q7wp1s 4bNeF5jD5eJof6lMCczRblSNckef5Y/6wOcFi639p5rgk7XVwRAQ+P76XcCFkvjr3in2eo lPMhAYscsL9nKo1/u2hzq3Bgs3s4eS1nteWoKSWLCz2e1hdxVbIEzeqsOuCenbC7MD0/7O TijbVFg5zWjPh67s+EFe1DMHm46VEtKGRgxQXjIURBh31tRL4FMMNrB/MzYK2eptcHcWIH 9L3tHFTG3lZH4YgKqHrlJdwTz123nmKr0sVLo09RQhqZBO+sLxdrgxfQm1q8ag== 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 4NpWHb10Z9zfHy; Fri, 6 Jan 2023 17:56:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 306Huhp4094254; Fri, 6 Jan 2023 17:56:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 306Huh6P094253; Fri, 6 Jan 2023 17:56:43 GMT (envelope-from git) Date: Fri, 6 Jan 2023 17:56:43 GMT Message-Id: <202301061756.306Huh6P094253@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alan Somers Subject: git: 3f8ca7a22ed9 - main - fsx: bounds check the inputs 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3f8ca7a22ed917a3e3a4ad78538d9f468d6d3bd8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=3f8ca7a22ed917a3e3a4ad78538d9f468d6d3bd8 commit 3f8ca7a22ed917a3e3a4ad78538d9f468d6d3bd8 Author: Alan Somers AuthorDate: 2023-01-07 01:54:23 +0000 Commit: Alan Somers CommitDate: 2023-01-07 01:54:23 +0000 fsx: bounds check the inputs In particular, don't allow the user to specify a file size that can't be expressed as an int, since fsx's random-number generator only has a 32 bit range. MFC after: 2 weeks --- tools/regression/fsx/fsx.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tools/regression/fsx/fsx.c b/tools/regression/fsx/fsx.c index 9bf61ffadb09..e84eeb503d42 100644 --- a/tools/regression/fsx/fsx.c +++ b/tools/regression/fsx/fsx.c @@ -105,13 +105,13 @@ int fd; /* fd for our test file */ off_t file_size = 0; off_t biggest = 0; char state[256]; -unsigned long testcalls = 0; /* calls to function "test" */ +long testcalls = 0; /* calls to function "test" */ -unsigned long simulatedopcount = 0; /* -b flag */ +long simulatedopcount = 0; /* -b flag */ int closeprob = 0; /* -c flag */ int invlprob = 0; /* -i flag */ int debug = 0; /* -d flag */ -unsigned long debugstart = 0; /* -D flag */ +long debugstart = 0; /* -D flag */ off_t maxfilelen = 256 * 1024; /* -l flag */ int sizechecks = 1; /* -n flag disables them */ int maxoplen = 64 * 1024; /* -o flag */ @@ -910,7 +910,7 @@ usage(void) -c P: 1 in P chance of file close+open at each op (default infinity)\n\ -d: debug output for all operations\n\ -i P: 1 in P chance of calling msync(MS_INVALIDATE) (default infinity)\n\ - -l flen: the upper bound on file size (default 262144)\n\ + -l flen: the upper bound on file size (default 262144, max 2147483647)\n\ -m startop:endop: monitor (print debug output) specified byte range (default 0:infinity)\n\ -n: no verifications of file size\n\ -o oplen: the upper bound on operation size (default 65536)\n\ @@ -937,32 +937,43 @@ usage(void) int getnum(char *s, char **e) { - int ret = -1; + long long ret = -1; *e = (char *) 0; - ret = strtol(s, e, 0); + ret = strtoll(s, e, 0); if (*e) switch (**e) { case 'b': case 'B': + if (ret > INT_MAX / 512) + return (-1); ret *= 512; *e = *e + 1; break; case 'k': case 'K': + if (ret > INT_MAX / 1024) + return (-1); ret *= 1024; *e = *e + 1; break; case 'm': case 'M': + if (ret > INT_MAX / 1024 / 1024) + return (-1); ret *= 1024*1024; *e = *e + 1; break; case 'w': case 'W': + if (ret > INT_MAX / 4) + return (-1); ret *= 4; *e = *e + 1; break; + default: + if (ret > INT_MAX) + return (-1); } return (ret); }