From nobody Fri Jan 27 19:28:10 2023 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 4P3SKQ5970z3brr4; Fri, 27 Jan 2023 19:28:10 +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 4P3SKQ4Pqpz45g4; Fri, 27 Jan 2023 19:28:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674847690; 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=+P/p7EIBZQUoUNyLD6a52BRgWEZNTzrUWPKsTvk+ums=; b=S8De+P7NLHhiiQ306fY81AIz8omfdgK69THeQ7MvRFLj4hB8oxh9MhAQeRwElmR01sCXWo LZOGMcMyvGCM2l8TKFUQ4m8aY0KVJg3BV54B48LgGvl5mvgTBV8PQK8qnPD26CI85XD76y k+iTkxkpug/rFVlV9kYyHQx9JwTiPnCoRC8phEuGhnmUW6XyyVWjmsK2zMaMiTIGyKQKL3 Ls7et1v5tnyMaplfuA6+Zk7uleNk0+0Z02aBjxKEotGaCD5rIJss1Qoc0WHCanDhtYybUh cMy6R6vLJdssPFdWeLApMcHftTw67Gt/bvt9M8fs6nTs11iqgGVHBDRfT+WaMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674847690; 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=+P/p7EIBZQUoUNyLD6a52BRgWEZNTzrUWPKsTvk+ums=; b=tTmqP3RzZR47kTbefziojP82PTPAwC4peoqQF7ZUMxWVH0kDrCqmkZWNxrlAsgqmnwqCGR SqZt6XPEEor3MWw5QDbJJuAbIQf1lwXaiBZI5UXv/MhjkSIZ022TKA8YZWJjQ5UAa4BilD BjIV8B48cHFqp6rodL6Ztded+YrudH5FUp7aDYq6vnyt13gvCMDzEZSGgo96hwVFKU17Iy jcsiEQrPR8dYu6IcnxOCjm7+dL1ebkM+jXogyryU0smwZp8ZMQ9FUWAnp/DgdG5jEZUJPs XoN/5N5RP1ybXoD5sXugnXzQatPZ673ilWud9ZCA3n4LjpoUMIXmAReX4/3APA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674847690; a=rsa-sha256; cv=none; b=DIgmW2tfvQgyV+AuOsnUkpYpVEnpd+wZxmXyvq0e2c5fP1bjt+sXzTq8n32R7yqrvnI1NJ iqFflJhy6bwYTwqj/vGFZni2zbsCkozPrpU8esBIo1roMKCkUs0/tZ2zEWVWGLk6gT4jz3 7cwYBtmqr9wGc8ykoY6lzZC9Sk+/jcvE84pN0owE2jHp/+Xb6U6QRcdIeVqUc0FJ4/PhoX UNSiyXC7fIU8obxUPXXreJANdr9H1eFJPNlS4tEcup+1uHurDWTubsbDPl6rJfMMi0x+T5 m3F/bfgyLHLlAU9EY6WX7dHdcqbg4Ua4wYDyDGN8tixpwGAXl1NTCjonLf8zlQ== 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 4P3SKQ36F2zLVc; Fri, 27 Jan 2023 19:28:10 +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 30RJSAc7029184; Fri, 27 Jan 2023 19:28:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30RJSAfN029183; Fri, 27 Jan 2023 19:28:10 GMT (envelope-from git) Date: Fri, 27 Jan 2023 19:28:10 GMT Message-Id: <202301271928.30RJSAfN029183@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: ae380bb8864f - stable/13 - fsx: bounds check the inputs 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: ae380bb8864f26e594ee4a4d1b08fdd70b50dc34 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=ae380bb8864f26e594ee4a4d1b08fdd70b50dc34 commit ae380bb8864f26e594ee4a4d1b08fdd70b50dc34 Author: Alan Somers AuthorDate: 2023-01-07 01:54:23 +0000 Commit: Alan Somers CommitDate: 2023-01-27 19:27:47 +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. (cherry picked from commit 3f8ca7a22ed917a3e3a4ad78538d9f468d6d3bd8) --- 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); }