From nobody Wed May 20 01:06:20 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 4gKtf46tsRz6drK4 for ; Wed, 20 May 2026 01:06:20 +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 4gKtf464t2z4LJp for ; Wed, 20 May 2026 01:06:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779239180; 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=5D9liE9aU/iYNLxmPRWVfXy10Uf7uRweqicCFjv6G4g=; b=txZQPuJXtu97tuJD9bVg4d0QNzqDF/pNLhc8V6QZ4e/xdgKcUG7hYaI98cdoldzvuRhiXg pbj1P9jBfVu0SNWbRBErr1BWkzQxnRM9IDhbGn8QWZ+WgyUr4aQlVMyW8q0oleseFPebVB CjlHOc0rkH6mrUgsf7Pl4GDmGWhXm4MXjyVVFrZ1/ivKJ8/gCml2ApFdjin0bm+rEDGOrd 63l9gcMbVQmRw54VjV58zYq2ID0Mp5mf/TUPZzoTnSPPwIYkrZssGiC2OkhT7qSTF0qjLS PCrXwmjOe4AoEm53XqvImVtsIQSFFqi6RGivq/bZk2eP1/fk7eVxPqxPZZLdLQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1779239180; a=rsa-sha256; cv=none; b=V0IuMtib8iKUOc+Wk8Pfdp/4hauY784tzUMI50pSoqbtYVfh3ZNadRHtih84yRKnaQsmBZ fP2DpWXEA2WghUv4WuwKh77C13kLqwsnXX6330EuTHQJrlogFrXW3lgVNHz7OHKfcmMZON QvA67+/F1ttIggq5cY7Luo2PJd0ejWQ/sCvhhHYj0JDxqsviFmR2tNl10XzB/6VXFSjvzW rdUpicZBYWo3CgVM8nIf/VI3OQsmeArPCL9Y6XjK4LuWM6x7F6qR8uD3KegFx3o7kczrY9 0Zaucv+/mdhuzZfk4Ds6tUE6L0QQhp+29lEqO5qbd6jEOxwBqgFuJiUm8/MB4w== 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=1779239180; 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=5D9liE9aU/iYNLxmPRWVfXy10Uf7uRweqicCFjv6G4g=; b=TmuUepa2Id99u34B4yARmOkHId0IQRcn1w8YIuMEYMyDu75PGzTjLGZ+WPHVf7AdW7hf3S iQxJfXgESgY+SpXvdp+e3UEGCukBTip0zd2JQELbsdyx5/zq/5G1eyCwADJyWYyhWA7Mbv +Q0e1CNda7LWlsYH5E5EJLu12yO/dNVEV9YZkj63DhtScn+AeyM6j5hSYHqDMuzfSKQG+/ csckBg2wwheAlVN3X9FoehDnDLe3pC5yygHTNTDC86T5EtSKNrD6s/GH8kv+ulE8TUfZlQ 8J3v3aifc3p88tD/moWJXYHHMGXJ2WVnwiiB86c8aY3pGlYQrxwTOhaoDrc/6Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gKtf459pJzgD7 for ; Wed, 20 May 2026 01:06:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 309ab by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 20 May 2026 01:06:20 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: af8675b11e3c - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: af8675b11e3c6b426ebd2cdb1fc5bfb9b1d06cff Auto-Submitted: auto-generated Date: Wed, 20 May 2026 01:06:20 +0000 Message-Id: <6a0d090c.309ab.17d922f@gitrepo.freebsd.org> The branch stable/14 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=af8675b11e3c6b426ebd2cdb1fc5bfb9b1d06cff commit af8675b11e3c6b426ebd2cdb1fc5bfb9b1d06cff Author: Rick Macklem AuthorDate: 2026-05-06 14:54:55 +0000 Commit: Rick Macklem CommitDate: 2026-05-20 00:04:41 +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 8bb51e29e1d1..ed61e6c9c804 100644 --- a/sys/fs/nfsclient/nfs_clsubs.c +++ b/sys/fs/nfsclient/nfs_clsubs.c @@ -268,9 +268,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 cc1959b7bf79..e66d135b0587 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];