From nobody Thu Nov 12 10:23:46 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 4jQGh23N4zz70N9L for ; Thu, 12 Nov 2026 10:23:46 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jQGh22KjWz4Ggm for ; Thu, 12 Nov 2026 10:23:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794479026; 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=JtB7F6JFQ4AGde4Zj4tgPlLHHGetco1P+UkmQS+4es8=; b=b7vQGKXOEyE8WXjMCrsUWnTnoQlfvAHQyk4UvWAmw6pNTHbLbmT/cosGljoMmJn5ep/+HL WeV+M2dRfJFtp4u/nDmj2sWpz80uiBLQdnIjEoPfq1bAQvkMxBRtFyTovohj43rhOm1lbw VmRg1SMz6uQrEChYteMxmTTkojX5vVidnar6AjLQp3WKViwlWW9HP7oURrcuqMdSMDzvlJ RD8NvWEjufxJNHwxYxwKWeMpoq7ekG9fciZH3TvgCFn36xUsIoGJMaRch49CPIcPf9HXKP TQCbh7kDAP+CyVfKQWVcZ/S3w/tg09oIwZRtzsy1Uztyo5ZaHvSyr6HW1v09Qw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794479026; b=NOH3462j3JzK1Iuv2M59fdXZagoNoPGbs9bdLOiYrS1E7U6QVO193jpCHmueap2l9Vno97 fQ6V+4KBBacdw3YenKjyxOXeHOudl1UN4aqRSEXR5ZPfDldffE7IMbXF+uLi1ipWpZpXKx cMx9DYBU8jejazmuRm/X9N8k7RfSLTQ7goAw/NCYKfKn07CVzD8lMWi553YrENbHiXckdw 0BtbanoyId7aNAaDexvavL/Njm9GmkT443ljcmrHLy6vqyOn+2DYXob3l4LD1RzQTWJlHX aCMneDMAH3m6dp2Uf5eTOUmpRIZi/wehIvy3YICdD0/DTw2VQWlQ7n2enkwTRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794479026; 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=JtB7F6JFQ4AGde4Zj4tgPlLHHGetco1P+UkmQS+4es8=; b=F+ab3c7y9qfXojU90NQX4iUlbI79AV+38Nvm4GxuuyyV6ORmhrEuy8aItqPFkGaI0OJzkN T2+/a+xFernZohiQ67tEgqbbA9tyaHCbAYIRfCxhxR9cR/VtaQQDEMOMpU2Qte9T5T/B8E iarwrqH8JhG+eZJIS/7ZwKAOSeFAP+W6+OwLQa9aAg+UP+EjO7OMCi0+dEPUS3JPoIW4mc 0CtpMoz1W4cmTITmDBseTroOxLt4VfYGkB60Imuk/HOTOTAyN6jA4S6XiMGuEbRapjiTIb IcVd6O1fR1/nUykVzN1LTs9fljglYrn5dKn8Lm2YnvBjvSYvSNYMAgQtrXf9OQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jQGh21y6kz102J for ; Thu, 12 Nov 2026 10:23:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 24d78 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 12 Nov 2026 10:23:46 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Brooks Davis Subject: git: f20c712f167a - main - extattr*(2): add kern_ and user_ implementaions List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository 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: brooks X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f20c712f167acd692240350179d4d98d33971375 Auto-Submitted: auto-generated Date: Thu, 12 Nov 2026 10:23:46 +0000 Message-Id: <6af593b2.24d78.1220c93@gitrepo.freebsd.org> The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=f20c712f167acd692240350179d4d98d33971375 commit f20c712f167acd692240350179d4d98d33971375 Author: Brooks Davis AuthorDate: 2026-11-12 10:23:23 +0000 Commit: Brooks Davis CommitDate: 2026-11-12 10:23:23 +0000 extattr*(2): add kern_ and user_ implementaions Effort: CHERI upstreaming Sponsored by: Innovate UK Pull Request: https://github.com/freebsd/freebsd-src/pull/2284 --- sys/kern/vfs_extattr.c | 114 ++++++++++++++++++++++++++++++------------------- sys/sys/syscallsubr.h | 20 +++++++++ 2 files changed, 89 insertions(+), 45 deletions(-) diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 01bfe343a1e4..70da1cdf56e2 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -47,17 +48,6 @@ #include #include -static int user_extattr_set_path(struct thread *td, const char *path, - int attrnamespace, const char *attrname, void *data, - size_t nbytes, int follow); -static int user_extattr_get_path(struct thread *td, const char *path, - int attrnamespace, const char *attrname, void *data, - size_t nbytes, int follow); -static int user_extattr_delete_path(struct thread *td, const char *path, - int attrnamespace, const char *attrname, int follow); -static int user_extattr_list_path(struct thread *td, const char *path, - int attrnamespace, void *data, size_t nbytes, int follow); - /* * Syscall to push extended attribute configuration information into the VFS. * Accepts a path, which it converts to a mountpoint, as well as a command @@ -76,6 +66,14 @@ struct extattrctl_args { #endif int sys_extattrctl(struct thread *td, struct extattrctl_args *uap) +{ + return (kern_extattrctl(td, uap->path, uap->cmd, uap->filename, + uap->attrnamespace, uap->attrname)); +} + +int +kern_extattrctl(struct thread *td, const char *path, int cmd, + const char *filename, int attrnamespace, const char *uattrname) { struct vnode *filename_vp; struct nameidata nd; @@ -83,14 +81,14 @@ sys_extattrctl(struct thread *td, struct extattrctl_args *uap) char attrname[EXTATTR_MAXNAMELEN + 1]; int error; - AUDIT_ARG_CMD(uap->cmd); - AUDIT_ARG_VALUE(uap->attrnamespace); + AUDIT_ARG_CMD(cmd); + AUDIT_ARG_VALUE(attrnamespace); /* - * uap->attrname is not always defined. We check again later when we + * attrname is not always defined. We check again later when we * invoke the VFS call so as to pass in NULL there if needed. */ - if (uap->attrname != NULL) { - error = copyinstr(uap->attrname, attrname, sizeof(attrname), + if (uattrname != NULL) { + error = copyinstr(uattrname, attrname, sizeof(attrname), NULL); if (error) return (error); @@ -99,9 +97,9 @@ sys_extattrctl(struct thread *td, struct extattrctl_args *uap) mp = NULL; filename_vp = NULL; - if (uap->filename != NULL) { + if (filename != NULL) { NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE2, UIO_USERSPACE, - uap->filename); + filename); error = namei(&nd); if (error) return (error); @@ -109,9 +107,9 @@ sys_extattrctl(struct thread *td, struct extattrctl_args *uap) NDFREE_PNBUF(&nd); } - /* uap->path is always defined. */ + /* path is always defined. */ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1, UIO_USERSPACE, - uap->path); + path); error = namei(&nd); if (error) goto out; @@ -131,7 +129,7 @@ sys_extattrctl(struct thread *td, struct extattrctl_args *uap) goto out; if (filename_vp != NULL) { /* - * uap->filename is not always defined. If it is, + * filename is not always defined. If it is, * grab a vnode lock, which VFS_EXTATTRCTL() will * later release. */ @@ -142,8 +140,8 @@ sys_extattrctl(struct thread *td, struct extattrctl_args *uap) } } - error = VFS_EXTATTRCTL(mp, uap->cmd, filename_vp, uap->attrnamespace, - uap->attrname != NULL ? attrname : NULL); + error = VFS_EXTATTRCTL(mp, cmd, filename_vp, attrnamespace, + uattrname != NULL ? attrname : NULL); vn_finished_write(mp_writable); out: @@ -229,15 +227,23 @@ struct extattr_set_fd_args { #endif int sys_extattr_set_fd(struct thread *td, struct extattr_set_fd_args *uap) +{ + return (user_extattr_set_fd(td, uap->fd, uap->attrnamespace, + uap->attrname, uap->data, uap->nbytes)); +} + +int +user_extattr_set_fd(struct thread *td, int fd, int attrnamespace, + const char *uattrname, void *data, size_t nbytes) { char attrname[EXTATTR_MAXNAMELEN + 1]; int error; - error = copyinstr(uap->attrname, attrname, sizeof(attrname), NULL); + error = copyinstr(uattrname, attrname, sizeof(attrname), NULL); if (error) return (error); - return (kern_extattr_set_fd(td, uap->fd, uap->attrnamespace, - attrname, uap->data, uap->nbytes)); + return (kern_extattr_set_fd(td, fd, attrnamespace, attrname, data, + nbytes)); } int @@ -285,7 +291,6 @@ struct extattr_set_file_args { int sys_extattr_set_file(struct thread *td, struct extattr_set_file_args *uap) { - return (user_extattr_set_path(td, uap->path, uap->attrnamespace, uap->attrname, uap->data, uap->nbytes, FOLLOW)); } @@ -302,12 +307,11 @@ struct extattr_set_link_args { int sys_extattr_set_link(struct thread *td, struct extattr_set_link_args *uap) { - return (user_extattr_set_path(td, uap->path, uap->attrnamespace, uap->attrname, uap->data, uap->nbytes, NOFOLLOW)); } -static int +int user_extattr_set_path(struct thread *td, const char *path, int attrnamespace, const char *uattrname, void *data, size_t nbytes, int follow) { @@ -426,15 +430,23 @@ struct extattr_get_fd_args { #endif int sys_extattr_get_fd(struct thread *td, struct extattr_get_fd_args *uap) +{ + return (user_extattr_get_fd(td, uap->fd, uap->attrnamespace, + uap->attrname, uap->data, uap->nbytes)); +} + +int +user_extattr_get_fd(struct thread *td, int fd, int attrnamespace, + const char *uattrname, void *data, size_t nbytes) { char attrname[EXTATTR_MAXNAMELEN + 1]; int error; - error = copyinstr(uap->attrname, attrname, sizeof(attrname), NULL); + error = copyinstr(uattrname, attrname, sizeof(attrname), NULL); if (error) return (error); - return (kern_extattr_get_fd(td, uap->fd, uap->attrnamespace, - attrname, uap->data, uap->nbytes)); + return (kern_extattr_get_fd(td, fd, attrnamespace, attrname, data, + nbytes)); } int @@ -502,7 +514,7 @@ sys_extattr_get_link(struct thread *td, struct extattr_get_link_args *uap) uap->attrname, uap->data, uap->nbytes, NOFOLLOW)); } -static int +int user_extattr_get_path(struct thread *td, const char *path, int attrnamespace, const char *uattrname, void *data, size_t nbytes, int follow) { @@ -591,15 +603,22 @@ struct extattr_delete_fd_args { #endif int sys_extattr_delete_fd(struct thread *td, struct extattr_delete_fd_args *uap) +{ + return (user_extattr_delete_fd(td, uap->fd, uap->attrnamespace, + uap->attrname)); +} + +int +user_extattr_delete_fd(struct thread *td, int fd, int attrnamespace, + const char *uattrname) { char attrname[EXTATTR_MAXNAMELEN + 1]; int error; - error = copyinstr(uap->attrname, attrname, sizeof(attrname), NULL); + error = copyinstr(uattrname, attrname, sizeof(attrname), NULL); if (error) return (error); - return (kern_extattr_delete_fd(td, uap->fd, uap->attrnamespace, - attrname)); + return (kern_extattr_delete_fd(td, fd, attrnamespace, attrname)); } int @@ -756,17 +775,25 @@ struct extattr_list_fd_args { #endif int sys_extattr_list_fd(struct thread *td, struct extattr_list_fd_args *uap) +{ + return (user_extattr_list_fd(td, uap->fd, uap->attrnamespace, + uap->data, uap->nbytes)); +} + +int +user_extattr_list_fd(struct thread *td, int fd, int attrnamespace, void *data, + size_t nbytes) { struct uio auio, *auiop; struct iovec aiov; - if (uap->data != NULL) { - aiov.iov_base = uap->data; - aiov.iov_len = uap->nbytes; + if (data != NULL) { + aiov.iov_base = data; + aiov.iov_len = nbytes; auio.uio_iov = &aiov; auio.uio_iovcnt = 1; auio.uio_offset = 0; - auio.uio_resid = uap->nbytes; + auio.uio_resid = nbytes; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; auio.uio_td = td; @@ -774,8 +801,7 @@ sys_extattr_list_fd(struct thread *td, struct extattr_list_fd_args *uap) } else auiop = NULL; - return (kern_extattr_list_fd(td, uap->fd, uap->attrnamespace, - auiop)); + return (kern_extattr_list_fd(td, fd, attrnamespace, auiop)); } int @@ -818,7 +844,6 @@ struct extattr_list_file_args { int sys_extattr_list_file(struct thread *td, struct extattr_list_file_args *uap) { - return (user_extattr_list_path(td, uap->path, uap->attrnamespace, uap->data, uap->nbytes, FOLLOW)); } @@ -834,12 +859,11 @@ struct extattr_list_link_args { int sys_extattr_list_link(struct thread *td, struct extattr_list_link_args *uap) { - return (user_extattr_list_path(td, uap->path, uap->attrnamespace, uap->data, uap->nbytes, NOFOLLOW)); } -static int +int user_extattr_list_path(struct thread *td, const char *path, int attrnamespace, void *data, size_t nbytes, int follow) { diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h index df354fda9dc7..5c46451b516f 100644 --- a/sys/sys/syscallsubr.h +++ b/sys/sys/syscallsubr.h @@ -206,6 +206,8 @@ int kern_dup(struct thread *td, u_int mode, int flags, int oldd, int newd); int kern_execve(struct thread *td, struct image_args *args, struct mac *mac_p, struct vmspace *oldvmspace); void kern_exit(struct thread *, int, int); +int kern_extattrctl(struct thread *td, const char *path, int cmd, + const char *filename, int attrnamespace, const char *uattrname); int kern_extattr_delete_fd(struct thread *td, int fd, int attrnamespace, const char *attrname); int kern_extattr_delete_fp(struct thread *td, struct file *fp, @@ -586,6 +588,24 @@ int user_cpuset_getaffinity(struct thread *td, cpulevel_t level, int user_cpuset_setaffinity(struct thread *td, cpulevel_t level, cpuwhich_t which, id_t id, size_t cpusetsize, const cpuset_t *maskp, const struct cpuset_copy_cb *cb); +int user_extattr_delete_fd(struct thread *td, int fd, int attrnamespace, + const char *uattrname); +int user_extattr_delete_path(struct thread *td, const char *path, + int attrnamespace, const char *attrname, int follow); +int user_extattr_get_fd(struct thread *td, int fd, int attrnamespace, + const char *uattrname, void *data, size_t nbytes); +int user_extattr_get_path(struct thread *td, const char *path, + int attrnamespace, const char *attrname, void *data, + size_t nbytes, int follow); +int user_extattr_list_fd(struct thread *td, int fd, int attrnamespace, + void *data, size_t nbytes); +int user_extattr_list_path(struct thread *td, const char *path, + int attrnamespace, void *data, size_t nbytes, int follow); +int user_extattr_set_fd(struct thread *td, int fd, int attrnamespace, + const char *uattrname, void *data, size_t nbytes); +int user_extattr_set_path(struct thread *td, const char *path, + int attrnamespace, const char *attrname, void *data, + size_t nbytes, int follow); int user_fspacectl(struct thread *td, int fd, int cmd, const struct spacectl_range *rqsrp, int flags, struct spacectl_range *rmsrp);