From nobody Wed May 20 01:03:33 2026 X-Original-To: dev-commits-src-branches@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 4gKtZs4mwdz6drJ2 for ; Wed, 20 May 2026 01:03:33 +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 4gKtZs4Bpnz4L8R for ; Wed, 20 May 2026 01:03:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779239013; 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=UGDREK/IiKTvMDMdQ3YmZB7ka4UmSFW0JoV0MMQjJZlFoyLUGh5W4Li2nAiUYNBLv9B7cJ JEt+o0/oUgGz6BpOR4PTwkZkjl+SABe37oO2WsbkwkVvuBj1EfMM2q2liQ3ZWPD9q68DY0 Sq3529hzYblW9pEPYIMY2Lz+ptaKsLkEhW5pXU5BX3fKwm8bOTfKdud2Q6dyuVlA0quPs5 1ry4ZOg3v9IO2I/G9iHzHtkypXtgG9yCCFyw8Ne8GcKrPu1ZC78Cq4Np9qMSlCBLziUB0H 6MDlv1v7bSSmCdLkJTZrHnQYb+ypja1Wk0lbbkkTqPGygrUqaDrMiHq8wUPSQQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1779239013; a=rsa-sha256; cv=none; b=SBGTe6RGAJnr+IX0byr0sq4VWj4ioLkyKXHX8xCkrUOMj8WF7cQSQfDDvSY7Xny0y9Duy4 v5QWK+BtoDm3Oxilb8U102a8Cs8I9OiS1PdJ8J5kF1brwZwIvINGHemr+b8CsZ24j9DP8n oAYKzY6nKJafUM4QOCRCZmAf1fjtzfFy3PoHhhGgkgpUyvAyhNK2+0i4VJeNR0v9yhU4S4 VhUw9qL/l/1tgTJkVVq6Q+w5ZS560pXFyBVNyH7t4kC2b+GMdb5oywcyJRvY67TQCrRaBs J7QoXYrCJVj6LPBcYrQQ/9skf9d668dheo2DNDZm/aL4FUApVNOQ4dYHo4ptYw== 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=1779239013; 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=apI4wLAIK6eeX/8D1ZuGFkHBFNy2Y2rt6a3zHVKnKNaLUI7R4NKwYIECU05H/DnYFtHgwW arlt6I70Fh82FVK0Qg0xU6rgaVWVJJhsIrYWCBBuCd4Nn3xYBrVqNhRgcWK/vpxbb2yIwH +q1lfClbS7IIJirnO0kCVDaYSC/oOycPhdbTEEu5k7QdgtBiqD4WDz8E0hwg5WTxcphtK5 s/cFeYRhS1/OwKvUr4OOcnSrpeYN2k9Czxc6VApPH1Jj0KhrcgoOzTkT0I/uzTk6IMfQDm TrVYbf/r65dPUQVuR85bUdK5sJzQgCNh44Uht4Go1glVWxk2uLi7sVAVUC789A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gKtZs3p3bzfwc for ; Wed, 20 May 2026 01:03:33 +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: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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];