From nobody Wed May 06 14:56:24 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 4g9dkQ2hBgz6ckGw for ; Wed, 06 May 2026 14:56:30 +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 4g9dkQ1BD4z3PF3 for ; Wed, 06 May 2026 14:56:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1778079390; 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=46yxfO9VL+m7lD80l/J80+2ja3Y2J0dXWFHDCz67RFY=; b=OdNHN3Zpes7UY7gNzHtYmgTq3w1F7j31dLbED35GOhgr8v+xypm90zoON3rsvbs7mzS9Oa h2HaYv3wGB7ei35GEFMBax4Hftft5YLHp+PH8aD8bKMD8Dbt6PAhDeAd7VAWtDxZpmnV+l MLFo50Wqrg8CpFbgODF23U2+0v8FO+EOcK04kse+LcSvOZPGhT8xnhFAlh3kF/1Jz3iEWq mzJtuLGcAxBFgcv+cZJrZhPpmEHEStG4f52lQfVJx2YGhlLIqY+N40XuLiXzWlhyzOfBec 3hXZEfCix9YZsfFwAHeRImpruRmOxOhlrrl2Dl3fDTw9QESItRbtDffWzfdCGQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1778079390; a=rsa-sha256; cv=none; b=h15A8hhdBdYuVzZizjrc/eDsjPN4bGfLNhC7u4BFWwgcjqq+JJ0LKQFrMobDcjC8TWHYpV 7QpQMhS/Nh0m7efQyFcNNlsFckKAQgbhiFEdTSPrlbKwZGSFHnTEN2YfvUHO2UrdzAK0xg lkb2FRhgOvFoZhW+25yydtd/mjaMrmkb6jC2fdGGeV9zE5VLuaSCSxOS/DAalm25DAqTuV 72cMwNORoxU6vUCimO9Vtwaywzk6pb7Ld5JUpBrA3znYNR1X8uPtNVQEf1PXy8PP8kw01H RjaKx2be/GyHim7nFrDrVLbWKuaYOlWlTgHztxplAdhB2immkVK8c0oK/NxXrA== 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=1778079390; 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=46yxfO9VL+m7lD80l/J80+2ja3Y2J0dXWFHDCz67RFY=; b=iLjZqXVFDLg7F+1tLSI9cj+AmJeqmTgJNOc3vYen6sRyiE6GoxbvVpmmkSkO1a+UjJmPhy zLBxS5tRkNIsn1Io9U5U53QJsmekvIwinVyaCw2wHp4TViTUtSpMem00UcqpZCs5KOM+ek vqvVsvYoccB2ANYrYc+bVTVG2tty0yEF+vHtx/HNCU0tCop9oF0S7K+xKwHRgqK1NTK5V/ C6mHNSsyAYLSt/CtwwVTTX/aNQAbqUmxJtD+ECWxxFr4R8CYT7BjSPjXUb0IZahfbmEt0W zQl7lBB1JvpvHbAR6z5n6fcukMYSCpU5KmCQVEfTuBgwEFbT0IELuwvrESTqCw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4g9dkQ0QhmzkW5 for ; Wed, 06 May 2026 14:56:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 192f8 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 06 May 2026 14:56:24 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 448b4c3f7f7d - main - 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/main X-Git-Reftype: branch X-Git-Commit: 448b4c3f7f7dd4c7e1707d7b833a26294c297182 Auto-Submitted: auto-generated Date: Wed, 06 May 2026 14:56:24 +0000 Message-Id: <69fb5698.192f8.3f1d837b@gitrepo.freebsd.org> The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=448b4c3f7f7dd4c7e1707d7b833a26294c297182 commit 448b4c3f7f7dd4c7e1707d7b833a26294c297182 Author: Rick Macklem AuthorDate: 2026-05-06 14:54:55 +0000 Commit: Rick Macklem CommitDate: 2026-05-06 14:54:55 +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. Reviewed by: markj Reported by: Joshua Rogers of AISLE Research Team MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D56779 --- 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];