From nobody Tue Jun 17 06:11:41 2025 X-Original-To: dev-commits-src-main@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 4bLxMy3dHFz5ptv9; Tue, 17 Jun 2025 06:11:42 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bLxMx72lhz4Fw1; Tue, 17 Jun 2025 06:11:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750140702; 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=cP9mvVxru52ZreaB3MPiV1cccOtapQ90F7RUdYXR+VU=; b=LOKnQgMYMYb/atC721RYGGIPNh15kSMPuZVm7F7pWRqnB5NxjPNU0GbzoHS/23qziu0rVA WIVLQ5Cb7H0M/bSsRb1959jtEQ8bgJMTVnfZ4+CslY6SCMoBPyytdp1Bzy0v9R0ZQssLjx sYQeMP5Iqv1EM/v9JDBDYe9OOW05YWe0mXq4qaXNOhe8Si0fbhAewcHg9V9gsItH0964Ur XFAvp/NZWhpV1xrZDpuTClJlA/EZhKZnHklSb7Hf0lOZEzhbCfs0HzQJjfn+6V5Dx3Bnu9 RtPgXuFRWsZD1FzUqN9ffiWIOud9ZgKGDhR6J+3YS/aLpU/2bv/ksbo/K0Hgdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750140702; 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=cP9mvVxru52ZreaB3MPiV1cccOtapQ90F7RUdYXR+VU=; b=Zl1Jps8zrgeoUcbXFdh4wDZyZ/CJTdFhe+/dAU6jdo0haAb3ILjFZF4q5Z/PLEOHblhTgr 0RgfxV2J7LYKqg5xiJ1wIFhMwrfQvgtv5SbJcMs3HchGCzC4neS5nCnIMMK/c1lO/AqK/8 IZhRXRf+DLuIY65TxubFiuNRYhdX14ip/Ds3zve5JCO2yQcehu9EdcUAGvKn8Q5EZIzQpH 80oJLAcHxDBZHXTo3Ao8qESBQCnlpPKNv5sSipj7O1y+jXywv7ADhscuYO2i0XvWvA+j0N urNJuVIZitt/nNHVGHrt7Hm+GAfQ+9TF+U8cyTXb+YB93pAJYDt7Gb3ySEZGpg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1750140702; a=rsa-sha256; cv=none; b=chzcRW8EJr2BtvPllvGnagqvnbSnwq/94uX+wT1HhMMCB+XYyDrED8wo862JEXjn60AbFj su2Sw3ITRbWVe0ZoaSy5Nyn9N+AcoZJ+NPFkS1n1NX9x8oDkbDLTTMlxGLhIOjpgL+CVLm +vRynLG3EIGYmhkewAunT+ll/6Qjr84WcGPSEj2F19bx7bNDyw2cKTerpIvy9sW61KTA7c uwgYlbwldq+Gkuy7AD6j/oCTDyv84NAxXksHH3KDDzbO8ZDpIPHVCTADRgM2cVHNXKdIeS Bgzr6ycS2IfxBR6Wh4Et8I3OCNDP71/aAYBY/Ux9smouMORmlzadMQNJQ2XudQ== 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 4bLxMx6VFfzWsj; Tue, 17 Jun 2025 06:11:41 +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 55H6BfIa044655; Tue, 17 Jun 2025 06:11:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 55H6Bfgt044652; Tue, 17 Jun 2025 06:11:41 GMT (envelope-from git) Date: Tue, 17 Jun 2025 06:11:41 GMT Message-Id: <202506170611.55H6Bfgt044652@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Popov Subject: git: f9c9122d5ab9 - main - fusefs: First take on exterrorizing List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arrowd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f9c9122d5ab9b106ddc6897454350b31de838631 Auto-Submitted: auto-generated The branch main has been updated by arrowd: URL: https://cgit.FreeBSD.org/src/commit/?id=f9c9122d5ab9b106ddc6897454350b31de838631 commit f9c9122d5ab9b106ddc6897454350b31de838631 Author: Gleb Popov AuthorDate: 2025-06-13 10:38:35 +0000 Commit: Gleb Popov CommitDate: 2025-06-17 06:11:34 +0000 fusefs: First take on exterrorizing Reviewed by: kib, asomers Approved by: kib, asomers Differential Revision: https://reviews.freebsd.org/D50831 --- sys/fs/fuse/fuse_device.c | 34 +++++++++++++++++++++------------- sys/fs/fuse/fuse_vfsops.c | 33 +++++++++++++++++++++------------ sys/sys/exterr_cat.h | 1 + 3 files changed, 43 insertions(+), 25 deletions(-) diff --git a/sys/fs/fuse/fuse_device.c b/sys/fs/fuse/fuse_device.c index 0a5da63c1f54..b0c886d4b120 100644 --- a/sys/fs/fuse/fuse_device.c +++ b/sys/fs/fuse/fuse_device.c @@ -82,6 +82,8 @@ #include #include #include +#define EXTERR_CATEGORY EXTERR_CAT_FUSE +#include #include "fuse.h" #include "fuse_internal.h" @@ -193,7 +195,7 @@ fuse_device_filter(struct cdev *dev, struct knote *kn) kn->kn_fop = &fuse_device_wfiltops; error = 0; } else if (error == 0) { - error = EINVAL; + error = EXTERROR(EINVAL, "Unsupported kevent filter"); kn->kn_data = error; } @@ -319,7 +321,7 @@ again: "we know early on that reader should be kicked so we " "don't wait for news"); fuse_lck_mtx_unlock(data->ms_mtx); - return (ENODEV); + return (EXTERROR(ENODEV, "This FUSE session is about to be closed")); } if (!(tick = fuse_ms_pop(data))) { /* check if we may block */ @@ -331,7 +333,10 @@ again: err = msleep(data, &data->ms_mtx, PCATCH, "fu_msg", 0); if (err != 0) { fuse_lck_mtx_unlock(data->ms_mtx); - return (fdata_get_dead(data) ? ENODEV : err); + if (fdata_get_dead(data)) + err = EXTERROR(ENODEV, + "This FUSE session is about to be closed"); + return (err); } tick = fuse_ms_pop(data); } @@ -361,8 +366,8 @@ again: FUSE_ASSERT_MS_DONE(tick); fuse_ticket_drop(tick); } - return (ENODEV); /* This should make the daemon get off - * of us */ + /* This should make the daemon get off of us */ + return (EXTERROR(ENODEV, "This FUSE session is about to be closed")); } SDT_PROBE2(fusefs, , device, trace, 1, "fuse device read message successfully"); @@ -385,7 +390,7 @@ again: fdata_set_dead(data); SDT_PROBE2(fusefs, , device, trace, 2, "daemon is stupid, kick it off..."); - err = ENODEV; + err = EXTERROR(ENODEV, "Partial read attempted"); } else { err = uiomove(buf, buflen, uio); } @@ -403,12 +408,14 @@ fuse_ohead_audit(struct fuse_out_header *ohead, struct uio *uio) SDT_PROBE2(fusefs, , device, trace, 1, "Format error: body size " "differs from size claimed by header"); - return (EINVAL); + return (EXTERROR(EINVAL, "Format error: body size " + "differs from size claimed by header")); } if (uio->uio_resid && ohead->unique != 0 && ohead->error) { SDT_PROBE2(fusefs, , device, trace, 1, "Format error: non zero error but message had a body"); - return (EINVAL); + return (EXTERROR(EINVAL, "Format error: non zero error, " + "but message had a body")); } return (0); @@ -444,7 +451,7 @@ fuse_device_write(struct cdev *dev, struct uio *uio, int ioflag) SDT_PROBE2(fusefs, , device, trace, 1, "fuse_device_write got less than a header!"); fdata_set_dead(data); - return (EINVAL); + return (EXTERROR(EINVAL, "fuse_device_write got less than a header!")); } if ((err = uiomove(&ohead, sizeof(struct fuse_out_header), uio)) != 0) return (err); @@ -452,7 +459,7 @@ fuse_device_write(struct cdev *dev, struct uio *uio, int ioflag) if (data->linux_errnos != 0 && ohead.error != 0) { err = -ohead.error; if (err < 0 || err >= nitems(linux_to_bsd_errtbl)) - return (EINVAL); + return (EXTERROR(EINVAL, "Unknown Linux errno", err)); /* '-', because it will get flipped again below */ ohead.error = -linux_to_bsd_errtbl[err]; @@ -520,7 +527,7 @@ fuse_device_write(struct cdev *dev, struct uio *uio, int ioflag) memcpy(&tick->tk_aw_ohead, &ohead, sizeof(ohead)); tick->tk_aw_handler(tick, uio); - err = EINVAL; + err = EXTERROR(EINVAL, "Unknown errno", ohead.error); } else { memcpy(&tick->tk_aw_ohead, &ohead, sizeof(ohead)); @@ -570,7 +577,8 @@ fuse_device_write(struct cdev *dev, struct uio *uio, int ioflag) /* Unimplemented. See comments in fuse_vnops */ default: /* Not implemented */ - err = ENOSYS; + err = EXTERROR(ENOSYS, "Unimplemented FUSE notification code", + ohead.error); } vfs_unbusy(mp); } else { @@ -589,7 +597,7 @@ fuse_device_write(struct cdev *dev, struct uio *uio, int ioflag) */ err = 0; } else { - err = EINVAL; + err = EXTERROR(ENOSYS, "FUSE ticket is missing"); } } diff --git a/sys/fs/fuse/fuse_vfsops.c b/sys/fs/fuse/fuse_vfsops.c index 48b84d3c75af..1b858a988289 100644 --- a/sys/fs/fuse/fuse_vfsops.c +++ b/sys/fs/fuse/fuse_vfsops.c @@ -81,6 +81,8 @@ #include #include #include +#define EXTERR_CATEGORY EXTERR_CAT_FUSE +#include #include "fuse.h" #include "fuse_node.h" @@ -272,7 +274,7 @@ fuse_vfsop_fhtovp(struct mount *mp, struct fid *fhp, int flags, int error; if (!(fuse_get_mpdata(mp)->dataflags & FSESS_EXPORT_SUPPORT)) - return EOPNOTSUPP; + return (EXTERROR(EOPNOTSUPP, "NFS-style lookups are not supported")); error = VFS_VGET(mp, ffhp->nid, LK_EXCLUSIVE, &nvp); if (error) { @@ -321,11 +323,11 @@ fuse_vfsop_mount(struct mount *mp) opts = mp->mnt_optnew; if (!opts) - return EINVAL; + return (EXTERROR(EINVAL, "Mount options were not supplied")); /* `fspath' contains the mount point (eg. /mnt/fuse/sshfs); REQUIRED */ if (!vfs_getopts(opts, "fspath", &err)) - return err; + return (EXTERROR(err, "Mount options are missing 'fspath'")); /* * With the help of underscored options the mount program @@ -358,11 +360,12 @@ fuse_vfsop_mount(struct mount *mp) /* `from' contains the device name (eg. /dev/fuse0); REQUIRED */ fspec = vfs_getopts(opts, "from", &err); if (!fspec) - return err; + return (EXTERROR(err, "Mount options are missing 'from'")); /* `fd' contains the filedescriptor for this session; REQUIRED */ if (vfs_scanopt(opts, "fd", "%d", &fd) != 1) - return EINVAL; + return (EXTERROR(EINVAL, "Mount options contain an invalid value " + "for 'fd'")); err = fuse_getdevice(fspec, td, &fdev); if (err != 0) @@ -398,11 +401,17 @@ fuse_vfsop_mount(struct mount *mp) /* Sanity + permission checks */ if (!data->daemoncred) panic("fuse daemon found, but identity unknown"); - if (mntopts & FSESS_DAEMON_CAN_SPY) + if (mntopts & FSESS_DAEMON_CAN_SPY) { err = priv_check(td, PRIV_VFS_FUSE_ALLOWOTHER); - if (err == 0 && td->td_ucred->cr_uid != data->daemoncred->cr_uid) + EXTERROR(err, "FUSE daemon requires privileges " + "due to 'allow_other' option"); + } + if (err == 0 && td->td_ucred->cr_uid != data->daemoncred->cr_uid) { /* are we allowed to do the first mount? */ err = priv_check(td, PRIV_VFS_FUSE_MOUNT_NONUSER); + EXTERROR(err, "Mounting as a user that is different from the FUSE " + "daemon's requires privileges"); + } if (err) { FUSE_UNLOCK(); goto out; @@ -549,7 +558,7 @@ fuse_vfsop_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp) * nullfs mount of a fusefs file system. */ SDT_PROBE1(fusefs, , vfsops, invalidate_without_export, mp); - return (EOPNOTSUPP); + return (EXTERROR(EOPNOTSUPP, "NFS-style lookups are not supported")); } error = fuse_internal_get_cached_vnode(mp, ino, flags, vpp); @@ -580,10 +589,10 @@ fuse_vfsop_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp) * Something is very wrong with the server if "foo/." has a * different inode number than "foo". */ - fuse_warn(data, FSESS_WARN_DOT_LOOKUP, - "Inconsistent LOOKUP response: \"FILE/.\" has a different " - "inode number than \"FILE\"."); - error = EIO; + static const char exterr[] = "Inconsistent LOOKUP response: " + "\"FILE/.\" has a different inode number than \"FILE\"."; + fuse_warn(data, FSESS_WARN_DOT_LOOKUP, exterr); + error = EXTERROR(EIO, exterr); goto out; } diff --git a/sys/sys/exterr_cat.h b/sys/sys/exterr_cat.h index adb474e84c1b..d770c274d7b7 100644 --- a/sys/sys/exterr_cat.h +++ b/sys/sys/exterr_cat.h @@ -15,6 +15,7 @@ #define EXTERR_CAT_FILEDESC 2 #define EXTERR_KTRACE 3 /* To allow inclusion of this file into kern_ktrace.c */ +#define EXTERR_CAT_FUSE 4 #endif