From nobody Mon Aug 25 08:57:18 2025 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 4c9PnB4mpDz65S55; Mon, 25 Aug 2025 08:57:18 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4c9PnB4H8Dz3pXQ; Mon, 25 Aug 2025 08:57:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756112238; 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=taqcWeRZrwrMkoll1FvfnTU8dnMAoCQ2Yg5TMNmS38Y=; b=cJQi5XNLZ1YuV73JG+McaJpLhzPXJAcgsliOsxYinKuYRPRJ/lavPK+cOrino/CevOlIDC Y2cM6uw8Na4M662FKga+8gIXCJdHFJbXO9tNTn1WRJDLUrQM/n13rgucZTXUOh9+McA6Ys QLDeNaIVzoy0xycElYZ3nhzb0YfsXNztUcoR2tz4iSKqABWfKcTs1aU78ARCw5MS18DhIP ziQJSXOB0/DhoIp2O6y/XQbir6mylMkoxa8i2zu9LV36+JPQmCF7BzEJlNydS9T5/kt7Ce 7CWh8KKCvnQUdkHsgmWiflKverIdzhuKNDF08A1YvENNJAmlbK233/5yJOjrug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756112238; 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=taqcWeRZrwrMkoll1FvfnTU8dnMAoCQ2Yg5TMNmS38Y=; b=YIyA5oas0pxrDgMjrk4cZQvH22v/RwCukUg400nR9pdIQbPjJJvqimt/fnzMTJ/rIvkZ1Y Xt6GeAAJYkDBX92zaPbndL+HDIYHA3wuBdkcr7Dr6L0GVoROpdHaVbpWjMfSEO1uFXUlp+ filyq/IUlS9D2aNefhMpUds9NtDYETZTCftIzZuqqAY6oblPa5yzto4Lwo0YxQxxuGVCw/ qsN/X4VDVe03Lg6+PWO6xN5Y7rc9q461B6kZ2tgRvGg6klWOZCbsQICXmznhJhapUVp4FL NefRE0eVTi3YuAptQxHt0Bz5hbRw7SzbVLxt2y3RlF6FZGrFim5YUpqUCJdUeg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1756112238; a=rsa-sha256; cv=none; b=p3nb9Zf4F4aInL2VnX2OBtMi9jwATfoi0IwTJ2T9tf76dXcn3SqrdWQZXq42mEd3BODL8/ SlcqhHXRfLUjrVs1dY4RZ6zvYI0h4sQhF1cadtXg+YHFpfqRmklr2CK4h9ThjBwbkaj8m6 Vp0Y0lZyUrz9XM/eD/igfrW6DCLyppjoANRYZCsKeIPZov9hVI45udv9Twj1C4DOaqy/9g T0BncxHSs5G1wqgYLtY1pBRnJuhGYbUyMmMP0tA/HkVrsOorr0CP3BizxYBnQxzc0U6HZ7 ULaBtlmbfWvfHoZYaRppDla0pIs1w38gfrhUbiG8tQ9khT6HBJ86r/eH6ZIaAA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4c9PnB3n0MzjKd; Mon, 25 Aug 2025 08:57:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 57P8vI8j016573; Mon, 25 Aug 2025 08:57:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 57P8vIYp016570; Mon, 25 Aug 2025 08:57:18 GMT (envelope-from git) Date: Mon, 25 Aug 2025 08:57:18 GMT Message-Id: <202508250857.57P8vIYp016570@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 828b4f1476c2 - stable/14 - zfsctl_root_readdir: if there were no dirents to copy out, return EINVAL 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 828b4f1476c24ee3026d7944646363c49484d9f6 Auto-Submitted: auto-generated The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=828b4f1476c24ee3026d7944646363c49484d9f6 commit 828b4f1476c24ee3026d7944646363c49484d9f6 Author: Konstantin Belousov AuthorDate: 2025-08-16 02:40:17 +0000 Commit: Konstantin Belousov CommitDate: 2025-08-25 08:42:16 +0000 zfsctl_root_readdir: if there were no dirents to copy out, return EINVAL (cherry picked from commit cead6157cc1b748df29b32072f492d4f6afae65a) --- .../openzfs/module/os/freebsd/zfs/zfs_ctldir.c | 40 ++++++++++++++-------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c index 3f955b296f1e..0c0112c29ae7 100644 --- a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c +++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c @@ -673,6 +673,7 @@ zfsctl_root_readdir(struct vop_readdir_args *ap) zfs_uio_t uio; int *eofp = ap->a_eofflag; off_t dots_offset; + ssize_t orig_resid; int error; zfs_uio_init(&uio, ap->a_uio); @@ -692,13 +693,11 @@ zfsctl_root_readdir(struct vop_readdir_args *ap) return (0); } + orig_resid = zfs_uio_resid(&uio); error = sfs_readdir_common(zfsvfs->z_root, ZFSCTL_INO_ROOT, ap, &uio, &dots_offset); - if (error != 0) { - if (error == ENAMETOOLONG) /* ran out of destination space */ - error = 0; - return (error); - } + if (error != 0) + goto err; if (zfs_uio_offset(&uio) != dots_offset) return (SET_ERROR(EINVAL)); @@ -711,8 +710,11 @@ zfsctl_root_readdir(struct vop_readdir_args *ap) entry.d_reclen = sizeof (entry); error = vfs_read_dirent(ap, &entry, zfs_uio_offset(&uio)); if (error != 0) { - if (error == ENAMETOOLONG) - error = 0; +err: + if (error == ENAMETOOLONG) { + error = orig_resid == zfs_uio_resid(&uio) ? + EINVAL : 0; + } return (SET_ERROR(error)); } if (eofp != NULL) @@ -1057,17 +1059,21 @@ zfsctl_snapdir_readdir(struct vop_readdir_args *ap) zfs_uio_t uio; int *eofp = ap->a_eofflag; off_t dots_offset; + ssize_t orig_resid; int error; zfs_uio_init(&uio, ap->a_uio); + orig_resid = zfs_uio_resid(&uio); ASSERT3S(vp->v_type, ==, VDIR); error = sfs_readdir_common(ZFSCTL_INO_ROOT, ZFSCTL_INO_SNAPDIR, ap, &uio, &dots_offset); if (error != 0) { - if (error == ENAMETOOLONG) /* ran out of destination space */ - error = 0; + if (error == ENAMETOOLONG) { /* ran out of destination space */ + error = orig_resid == zfs_uio_resid(&uio) ? + EINVAL : 0; + } return (error); } @@ -1085,9 +1091,13 @@ zfsctl_snapdir_readdir(struct vop_readdir_args *ap) dsl_pool_config_exit(dmu_objset_pool(zfsvfs->z_os), FTAG); if (error != 0) { if (error == ENOENT) { - if (eofp != NULL) - *eofp = 1; - error = 0; + if (orig_resid == zfs_uio_resid(&uio)) { + error = EINVAL; + } else { + error = 0; + if (eofp != NULL) + *eofp = 1; + } } zfs_exit(zfsvfs, FTAG); return (error); @@ -1100,8 +1110,10 @@ zfsctl_snapdir_readdir(struct vop_readdir_args *ap) entry.d_reclen = sizeof (entry); error = vfs_read_dirent(ap, &entry, zfs_uio_offset(&uio)); if (error != 0) { - if (error == ENAMETOOLONG) - error = 0; + if (error == ENAMETOOLONG) { + error = orig_resid == zfs_uio_resid(&uio) ? + EINVAL : 0; + } zfs_exit(zfsvfs, FTAG); return (SET_ERROR(error)); }