From nobody Wed May 20 01:03:33 2026 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 4gKtZy73YTz6drRD for ; Wed, 20 May 2026 01:03:38 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gKtZy6Qt2z4KvM for ; Wed, 20 May 2026 01:03:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779239018; 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=RvjwYUHh6l/VmsV4QBfr9C5Z5KXkMk2WIDW/QKzpjek=; b=E8ugS8itrrNI/5PEMjoPD9q4zIOWfFgwPSndRLQ8lwdTzflmYZx5A4N8Wr8fQSsEX572+5 GN6LEezHNWd+gMrnPZS7qmblG54uz+xXQnJtXGoMkswwolg3nPbdGHe2+4HNU7lGanCF3a C3eI1QFI4disrzlOa6ILRNxLfgLL+edPMCWWT2rmyP6Nsxo+wxAPxv1324itLrxxBY55mm bFKjKajEhlc+BlDruVUDoSUKZgjcf8GRzchQHiL9J5X4ucEb3YcobC+uCMrYYu5gJH+hl6 oLe9R9qQkg6VZp1kntWVSOJfrqUYdqvv0xCMq9wnGsT8B7T4LBlxnTjMcVuZRw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1779239018; a=rsa-sha256; cv=none; b=AJxkNq4r3XHySa0Tz9qnUA/QDDUlnNIb3H+WnzP8oUvFZ7mqO5QjgPtrJCSYvxirQWezCN NJnpBmH56/uAacc1T0s0LF9d4x1jBnI0f0JGTYczyjNqyTS+EpXgmXxtUHrnrztEwsAoTr IXn14ga9Ebuv9DMTGRk8zRK9gTmbC9urYz6e0g1KQgpM5nqSqfjgxBaKuT7Dx+spR0tUdB ZUjn4qz01xjRCq5WjzxArVQjrUhHChpgh/BGUVvv0c4F8y799qCFAhC4LSnU5PicS1cBAE 3zl+wjMpJwrgwlkD89iLyRdCF/bP4jsCu03SNIgar5iesAsPMiS9BXQmBApmag== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779239018; 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=RvjwYUHh6l/VmsV4QBfr9C5Z5KXkMk2WIDW/QKzpjek=; b=vBHaOP1dpZtCSwHiZ93robe5vF2ylxEhZwxEvQf44wYVQqfRX+xNneX1csIQ1Nj03nbQYv +NgSgdtnAQZUdaP3Gz4K5BBjM/4XPqZuuvju/VWmAXK3gc+CpdzUYfO4/Vr4G4SHTXOhZI 5sJ/OPfPeu3xL02kvNgjuYkrC/3lya4QXOWnLZ7a1SgvDYbK8qQwlvWsx8dVlIvLTMpUQG eW08RHjMmg854O1w/qduQH6bR/aXrTHnLacXEuSRCdogBFyjBoBucgAGswhki8M+C1dx1q ykdz3MwxGIMbzASU0eCLJMiiybF5cpoT+Xll1RgqiYaDyqrJUI8gPtqAJ74H4w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gKtZy61Gtzfv1 for ; Wed, 20 May 2026 01:03:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3064e by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 20 May 2026 01:03:33 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 3aab0373ddb6 - stable/15 - nfs_clsubs.c: Fix ncl_getcookie() when "pos" is negative 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 List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 3aab0373ddb61e8c6b422c8a4368b708640da2e9 Auto-Submitted: auto-generated Date: Wed, 20 May 2026 01:03:33 +0000 Message-Id: <6a0d0865.3064e.6f6a0a22@gitrepo.freebsd.org> The branch stable/15 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=3aab0373ddb61e8c6b422c8a4368b708640da2e9 commit 3aab0373ddb61e8c6b422c8a4368b708640da2e9 Author: Rick Macklem AuthorDate: 2026-05-06 14:54:55 +0000 Commit: Rick Macklem CommitDate: 2026-05-20 00:01:44 +0000 nfs_clsubs.c: Fix ncl_getcookie() when "pos" is negative In ncl_getcookie(), a very large value for "off" for a directory can result in "pos" being set to a bogus value (including a negative one), due to truncation. When "pos" is negative, is can skip past the while (pos >= NFSNUMCOOKIES) loop and return a bogus pointer instead of NULL. This patch changes the type to u_int and also adds a sanity check for a very large "off" to ensure that a NULL pointer is returned for this case. This bug has been in the code for decades and I am not aware of any report of it causing a problem for users. (cherry picked from commit 448b4c3f7f7dd4c7e1707d7b833a26294c297182) --- sys/fs/nfsclient/nfs_clsubs.c | 10 +++++++++- sys/fs/nfsclient/nfsnode.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clsubs.c b/sys/fs/nfsclient/nfs_clsubs.c index ae9fa51947cc..6361ae5f2901 100644 --- a/sys/fs/nfsclient/nfs_clsubs.c +++ b/sys/fs/nfsclient/nfs_clsubs.c @@ -263,9 +263,17 @@ nfsuint64 * ncl_getcookie(struct nfsnode *np, off_t off, int add) { struct nfsdmap *dp, *dp2; - int pos; + u_int pos; nfsuint64 *retval = NULL; + /* + * Limiting "off" to 50Gbytes sets a limit of 100 million directory + * entries of maximum filename length. Much more with shorter + * file names. This limit ensures "pos" will not be truncated + * in the devision below. + */ + if (off > 53687091200ull) + goto out; pos = (uoff_t)off / NFS_DIRBLKSIZ; if (pos == 0 || off < 0) { KASSERT(!add, ("nfs getcookie add at <= 0")); diff --git a/sys/fs/nfsclient/nfsnode.h b/sys/fs/nfsclient/nfsnode.h index 07c7ccb0ff10..cd9ded943c2f 100644 --- a/sys/fs/nfsclient/nfsnode.h +++ b/sys/fs/nfsclient/nfsnode.h @@ -61,7 +61,7 @@ struct sillyrename { struct nfsdmap { LIST_ENTRY(nfsdmap) ndm_list; - int ndm_eocookie; + u_int ndm_eocookie; union { nfsuint64 ndmu3_cookies[NFSNUMCOOKIES]; uint64_t ndmu4_cookies[NFSNUMCOOKIES];