? acl-extattr-mpsafe.patch
Index: kern_acl.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_acl.c,v
retrieving revision 1.45
diff -u -r1.45 kern_acl.c
--- kern_acl.c	26 Jul 2004 07:24:03 -0000	1.45
+++ kern_acl.c	29 May 2005 18:26:04 -0000
@@ -773,14 +773,13 @@
 	struct nameidata nd;
 	int error;
 
-	mtx_lock(&Giant);
-	NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_USERSPACE, uap->path, td);
 	error = namei(&nd);
 	if (error == 0) {
 		error = vacl_get_acl(td, nd.ni_vp, uap->type, uap->aclp);
+		VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
 		NDFREE(&nd, 0);
 	}
-	mtx_unlock(&Giant);
 	return (error);
 }
 
@@ -795,14 +794,13 @@
 	struct nameidata nd;
 	int error;
 
-	mtx_lock(&Giant);
-	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_USERSPACE, uap->path, td);
 	error = namei(&nd);
 	if (error == 0) {
 		error = vacl_get_acl(td, nd.ni_vp, uap->type, uap->aclp);
+		VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
 		NDFREE(&nd, 0);
 	}
-	mtx_unlock(&Giant);
 	return (error);
 }
 
@@ -817,14 +815,13 @@
 	struct nameidata nd;
 	int error;
 
-	mtx_lock(&Giant);
-	NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_USERSPACE, uap->path, td);
 	error = namei(&nd);
 	if (error == 0) {
 		error = vacl_set_acl(td, nd.ni_vp, uap->type, uap->aclp);
+		VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
 		NDFREE(&nd, 0);
 	}
-	mtx_unlock(&Giant);
 	return (error);
 }
 
@@ -839,14 +836,13 @@
 	struct nameidata nd;
 	int error;
 
-	mtx_lock(&Giant);
-	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_USERSPACE, uap->path, td);
 	error = namei(&nd);
 	if (error == 0) {
 		error = vacl_set_acl(td, nd.ni_vp, uap->type, uap->aclp);
+		VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
 		NDFREE(&nd, 0);
 	}
-	mtx_unlock(&Giant);
 	return (error);
 }
 
@@ -861,13 +857,11 @@
 	struct file *fp;
 	int error;
 
-	mtx_lock(&Giant);
 	error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
 	if (error == 0) {
 		error = vacl_get_acl(td, fp->f_vnode, uap->type, uap->aclp);
 		fdrop(fp, td);
 	}
-	mtx_unlock(&Giant);
 	return (error);
 }
 
@@ -882,13 +876,11 @@
 	struct file *fp;
 	int error;
 
-	mtx_lock(&Giant);
 	error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
 	if (error == 0) {
 		error = vacl_set_acl(td, fp->f_vnode, uap->type, uap->aclp);
 		fdrop(fp, td);
 	}
-	mtx_unlock(&Giant);
 	return (error);
 }
 
@@ -903,14 +895,13 @@
 	struct nameidata nd;
 	int error;
 
-	mtx_lock(&Giant);
-	NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_USERSPACE, uap->path, td);
 	error = namei(&nd);
 	if (error == 0) {
 		error = vacl_delete(td, nd.ni_vp, uap->type);
+		VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
 		NDFREE(&nd, 0);
 	}
-	mtx_unlock(&Giant);
 	return (error);
 }
 
@@ -925,14 +916,13 @@
 	struct nameidata nd;
 	int error;
 
-	mtx_lock(&Giant);
-	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_USERSPACE, uap->path, td);
 	error = namei(&nd);
 	if (error == 0) {
 		error = vacl_delete(td, nd.ni_vp, uap->type);
+		VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
 		NDFREE(&nd, 0);
 	}
-	mtx_unlock(&Giant);
 	return (error);
 }
 
@@ -947,13 +937,11 @@
 	struct file *fp;
 	int error;
 
-	mtx_lock(&Giant);
 	error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
 	if (error == 0) {
 		error = vacl_delete(td, fp->f_vnode, uap->type);
 		fdrop(fp, td);
 	}
-	mtx_unlock(&Giant);
 	return (error);
 }
 
@@ -968,14 +956,13 @@
 	struct nameidata	nd;
 	int	error;
 
-	mtx_lock(&Giant);
-	NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_USERSPACE, uap->path, td);
 	error = namei(&nd);
 	if (error == 0) {
 		error = vacl_aclcheck(td, nd.ni_vp, uap->type, uap->aclp);
+		VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
 		NDFREE(&nd, 0);
 	}
-	mtx_unlock(&Giant);
 	return (error);
 }
 
@@ -990,14 +977,13 @@
 	struct nameidata	nd;
 	int	error;
 
-	mtx_lock(&Giant);
-	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_USERSPACE, uap->path, td);
 	error = namei(&nd);
 	if (error == 0) {
 		error = vacl_aclcheck(td, nd.ni_vp, uap->type, uap->aclp);
+		VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
 		NDFREE(&nd, 0);
 	}
-	mtx_unlock(&Giant);
 	return (error);
 }
 
@@ -1012,12 +998,10 @@
 	struct file *fp;
 	int error;
 
-	mtx_lock(&Giant);
 	error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
 	if (error == 0) {
 		error = vacl_aclcheck(td, fp->f_vnode, uap->type, uap->aclp);
 		fdrop(fp, td);
 	}
-	mtx_unlock(&Giant);
 	return (error);
 }
Index: syscalls.master
===================================================================
RCS file: /home/ncvs/src/sys/kern/syscalls.master,v
retrieving revision 1.194
diff -u -r1.194 syscalls.master
--- syscalls.master	28 May 2005 14:35:05 -0000	1.194
+++ syscalls.master	29 May 2005 18:26:04 -0000
@@ -498,16 +498,16 @@
 		    acl_type_t type, struct acl *aclp); }
 354	MSTD	{ int __acl_aclcheck_fd(int filedes, acl_type_t type, \
 		    struct acl *aclp); }
-355	STD	{ int extattrctl(const char *path, int cmd, \
+355	MSTD	{ int extattrctl(const char *path, int cmd, \
 		    const char *filename, int attrnamespace, \
 		    const char *attrname); }
-356	STD	{ int extattr_set_file(const char *path, \
+356	MSTD	{ int extattr_set_file(const char *path, \
 		    int attrnamespace, const char *attrname, \
 		    void *data, size_t nbytes); }
-357	STD	{ ssize_t extattr_get_file(const char *path, \
+357	MSTD	{ ssize_t extattr_get_file(const char *path, \
 		    int attrnamespace, const char *attrname, \
 		    void *data, size_t nbytes); }
-358	STD	{ int extattr_delete_file(const char *path, \
+358	MSTD	{ int extattr_delete_file(const char *path, \
 		    int attrnamespace, const char *attrname); }
 359	NOSTD	{ int aio_waitcomplete(struct aiocb **aiocbp, \
 		    struct timespec *timeout); }
@@ -525,12 +525,12 @@
 368	UNIMPL	__cap_set_fd
 369	UNIMPL	__cap_set_file
 370	NODEF	lkmressys lkmressys nosys_args int
-371	STD	{ int extattr_set_fd(int fd, int attrnamespace, \
+371	MSTD	{ int extattr_set_fd(int fd, int attrnamespace, \
 		    const char *attrname, void *data, \
 		    size_t nbytes); }
-372	STD	{ ssize_t extattr_get_fd(int fd, int attrnamespace, \
+372	MSTD	{ ssize_t extattr_get_fd(int fd, int attrnamespace, \
 		    const char *attrname, void *data, size_t nbytes); }
-373	STD	{ int extattr_delete_fd(int fd, int attrnamespace, \
+373	MSTD	{ int extattr_delete_fd(int fd, int attrnamespace, \
 		    const char *attrname); }
 374	MSTD	{ int __setugid(int flag); }
 375	NOIMPL	{ int nfsclnt(int flag, caddr_t argp); }
@@ -583,13 +583,13 @@
 		    struct mac *mac_p); }
 411	MSTD	{ int __mac_set_link(const char *path_p, \
 		    struct mac *mac_p); }
-412	STD	{ int extattr_set_link(const char *path, \
+412	MSTD	{ int extattr_set_link(const char *path, \
 		    int attrnamespace, const char *attrname, \
 		    void *data, size_t nbytes); }
-413	STD	{ ssize_t extattr_get_link(const char *path, \
+413	MSTD	{ ssize_t extattr_get_link(const char *path, \
 		    int attrnamespace, const char *attrname, \
 		    void *data, size_t nbytes); }
-414	STD	{ int extattr_delete_link(const char *path, \
+414	MSTD	{ int extattr_delete_link(const char *path, \
 		    int attrnamespace, const char *attrname); }
 415	MSTD	{ int __mac_execve(char *fname, char **argv, \
 		    char **envv, struct mac *mac_p); }
@@ -620,11 +620,11 @@
 434	MSTD	{ int _umtx_lock(struct umtx *umtx); }
 435	MSTD	{ int _umtx_unlock(struct umtx *umtx); }
 436	MSTD	{ int jail_attach(int jid); }
-437	STD	{ ssize_t extattr_list_fd(int fd, int attrnamespace, \
+437	MSTD	{ ssize_t extattr_list_fd(int fd, int attrnamespace, \
 		    void *data, size_t nbytes); }
-438	STD	{ ssize_t extattr_list_file(const char *path, \
+438	MSTD	{ ssize_t extattr_list_file(const char *path, \
 		    int attrnamespace, void *data, size_t nbytes); }
-439	STD	{ ssize_t extattr_list_link(const char *path, \
+439	MSTD	{ ssize_t extattr_list_link(const char *path, \
 		    int attrnamespace, void *data, size_t nbytes); }
 440	MSTD	{ int kse_switchin(struct kse_thr_mailbox *tmbx, \
 		    int flags); }
Index: vfs_syscalls.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/vfs_syscalls.c,v
retrieving revision 1.385
diff -u -r1.385 vfs_syscalls.c
--- vfs_syscalls.c	28 May 2005 13:11:35 -0000	1.385
+++ vfs_syscalls.c	29 May 2005 18:26:04 -0000
@@ -4318,23 +4318,25 @@
 	 */
 	filename_vp = NULL;
 	if (uap->filename != NULL) {
-		NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
+		NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | MPSAFE, UIO_USERSPACE,
 		    uap->filename, td);
 		error = namei(&nd);
 		if (error)
 			return (error);
+		VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
 		filename_vp = nd.ni_vp;
 		NDFREE(&nd, NDF_NO_VP_RELE | NDF_NO_VP_UNLOCK);
 	}
 
 	/* uap->path is always defined. */
-	NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_USERSPACE, uap->path, td);
 	error = namei(&nd);
 	if (error) {
 		if (filename_vp != NULL)
 			vput(filename_vp);
 		return (error);
 	}
+	VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
 	mp = nd.ni_vp->v_mount;
 	error = vn_start_write(nd.ni_vp, &mp_writable, V_WAIT | PCATCH);
 	NDFREE(&nd, 0);
@@ -4465,10 +4467,11 @@
 	if (error)
 		return (error);
 
-	NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_USERSPACE, uap->path, td);
 	error = namei(&nd);
 	if (error)
 		return (error);
+	VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
 	NDFREE(&nd, NDF_ONLY_PNBUF);
 
 	error = extattr_set_vp(nd.ni_vp, uap->attrnamespace, attrname,
@@ -4497,10 +4500,11 @@
 	if (error)
 		return (error);
 
-	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_USERSPACE, uap->path, td);
 	error = namei(&nd);
 	if (error)
 		return (error);
+	VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
 	NDFREE(&nd, NDF_ONLY_PNBUF);
 
 	error = extattr_set_vp(nd.ni_vp, uap->attrnamespace, attrname,
@@ -4629,10 +4633,11 @@
 	if (error)
 		return (error);
 
-	NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_USERSPACE, uap->path, td);
 	error = namei(&nd);
 	if (error)
 		return (error);
+	VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
 	NDFREE(&nd, NDF_ONLY_PNBUF);
 
 	error = extattr_get_vp(nd.ni_vp, uap->attrnamespace, attrname,
@@ -4661,10 +4666,11 @@
 	if (error)
 		return (error);
 
-	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_USERSPACE, uap->path, td);
 	error = namei(&nd);
 	if (error)
 		return (error);
+	VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
 	NDFREE(&nd, NDF_ONLY_PNBUF);
 
 	error = extattr_get_vp(nd.ni_vp, uap->attrnamespace, attrname,
@@ -4762,10 +4768,11 @@
 	if (error)
 		return(error);
 
-	NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_USERSPACE, uap->path, td);
 	error = namei(&nd);
 	if (error)
 		return(error);
+	VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
 	NDFREE(&nd, NDF_ONLY_PNBUF);
 
 	error = extattr_delete_vp(nd.ni_vp, uap->attrnamespace, attrname, td);
@@ -4790,10 +4797,11 @@
 	if (error)
 		return(error);
 
-	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_USERSPACE, uap->path, td);
 	error = namei(&nd);
 	if (error)
 		return(error);
+	VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
 	NDFREE(&nd, NDF_ONLY_PNBUF);
 
 	error = extattr_delete_vp(nd.ni_vp, uap->attrnamespace, attrname, td);
@@ -4903,10 +4911,11 @@
 	struct nameidata nd;
 	int error;
 
-	NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_USERSPACE, uap->path, td);
 	error = namei(&nd);
 	if (error)
 		return (error);
+	VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
 	NDFREE(&nd, NDF_ONLY_PNBUF);
 
 	error = extattr_list_vp(nd.ni_vp, uap->attrnamespace, uap->data,
@@ -4929,10 +4938,11 @@
 	struct nameidata nd;
 	int error;
 
-	NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
+	NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_USERSPACE, uap->path, td);
 	error = namei(&nd);
 	if (error)
 		return (error);
+	VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
 	NDFREE(&nd, NDF_ONLY_PNBUF);
 
 	error = extattr_list_vp(nd.ni_vp, uap->attrnamespace, uap->data,
