Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Change the vnode locking protocol of VOP_GETATTR() to re...
details: https://anonhg.NetBSD.org/src/rev/b6781a885c39
branches: trunk
changeset: 770358:b6781a885c39
user: hannken <hannken%NetBSD.org@localhost>
date: Fri Oct 14 09:23:28 2011 +0000
description:
Change the vnode locking protocol of VOP_GETATTR() to request at least
a shared lock. Make all calls outside of file systems respect it.
The calls from file systems need review.
No objections from tech-kern.
diffstat:
sys/compat/linux/common/linux_file.c | 6 ++++--
sys/compat/linux/common/linux_file64.c | 9 ++++++---
sys/compat/linux/common/linux_ioctl.c | 17 ++++++++++++-----
sys/compat/linux/common/linux_misc.c | 9 ++++++---
sys/compat/linux32/common/linux32_dirent.c | 9 ++++++---
sys/compat/ossaudio/ossaudio.c | 11 +++++++----
sys/compat/svr4/svr4_fcntl.c | 9 ++++++---
sys/compat/svr4_32/svr4_32_fcntl.c | 9 ++++++---
sys/dev/ccd.c | 9 ++++++---
sys/dev/cgd.c | 9 ++++++---
sys/dev/dm/dm_target_linear.c | 7 +++++--
sys/dev/dm/dm_target_snapshot.c | 21 +++++++++++++++------
sys/dev/dm/dm_target_stripe.c | 7 +++++--
sys/dev/raidframe/rf_copyback.c | 9 ++++++---
sys/dev/raidframe/rf_disks.c | 9 ++++++---
sys/dev/raidframe/rf_reconstruct.c | 9 ++++++---
sys/dev/vnd.c | 10 +++++++---
sys/kern/kern_verifiedexec.c | 6 ++++--
sys/kern/vfs_mount.c | 14 ++++++++++----
sys/kern/vfs_syscalls.c | 11 ++++++++---
sys/kern/vfs_vnops.c | 9 +++++----
sys/kern/vnode_if.src | 4 ++--
sys/uvm/uvm_mmap.c | 10 ++++++----
23 files changed, 150 insertions(+), 73 deletions(-)
diffs (truncated from 722 to 300 lines):
diff -r 31cd9eac5fd6 -r b6781a885c39 sys/compat/linux/common/linux_file.c
--- a/sys/compat/linux/common/linux_file.c Thu Oct 13 23:42:06 2011 +0000
+++ b/sys/compat/linux/common/linux_file.c Fri Oct 14 09:23:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_file.c,v 1.103 2011/04/14 00:59:06 christos Exp $ */
+/* $NetBSD: linux_file.c,v 1.104 2011/10/14 09:23:28 hannken Exp $ */
/*-
* Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.103 2011/04/14 00:59:06 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.104 2011/10/14 09:23:28 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -340,7 +340,9 @@
break;
}
+ vn_lock(vp, LK_SHARED | LK_RETRY);
error = VOP_GETATTR(vp, &va, l->l_cred);
+ VOP_UNLOCK(vp);
fd_putfile(fd);
diff -r 31cd9eac5fd6 -r b6781a885c39 sys/compat/linux/common/linux_file64.c
--- a/sys/compat/linux/common/linux_file64.c Thu Oct 13 23:42:06 2011 +0000
+++ b/sys/compat/linux/common/linux_file64.c Fri Oct 14 09:23:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_file64.c,v 1.52 2011/09/01 12:44:10 njoly Exp $ */
+/* $NetBSD: linux_file64.c,v 1.53 2011/10/14 09:23:28 hannken Exp $ */
/*-
* Copyright (c) 1995, 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.52 2011/09/01 12:44:10 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.53 2011/10/14 09:23:28 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -258,7 +258,10 @@
goto out1;
}
- if ((error = VOP_GETATTR(vp, &va, l->l_cred)))
+ vn_lock(vp, LK_SHARED | LK_RETRY);
+ error = VOP_GETATTR(vp, &va, l->l_cred);
+ VOP_UNLOCK(vp);
+ if (error)
goto out1;
nbytes = SCARG(uap, count);
diff -r 31cd9eac5fd6 -r b6781a885c39 sys/compat/linux/common/linux_ioctl.c
--- a/sys/compat/linux/common/linux_ioctl.c Thu Oct 13 23:42:06 2011 +0000
+++ b/sys/compat/linux/common/linux_ioctl.c Fri Oct 14 09:23:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_ioctl.c,v 1.55 2008/07/19 23:01:52 jmcneill Exp $ */
+/* $NetBSD: linux_ioctl.c,v 1.56 2011/10/14 09:23:28 hannken Exp $ */
/*-
* Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_ioctl.c,v 1.55 2008/07/19 23:01:52 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ioctl.c,v 1.56 2011/10/14 09:23:28 hannken Exp $");
#if defined(_KERNEL_OPT)
#include "sequencer.h"
@@ -128,6 +128,7 @@
* way. We do it by indexing in the cdevsw with the major
* device number and check if that is the sequencer entry.
*/
+ bool is_sequencer = false;
struct file *fp;
struct vnode *vp;
struct vattr va;
@@ -137,9 +138,15 @@
return EBADF;
if (fp->f_type == DTYPE_VNODE &&
(vp = (struct vnode *)fp->f_data) != NULL &&
- vp->v_type == VCHR &&
- VOP_GETATTR(vp, &va, l->l_cred) == 0 &&
- cdevsw_lookup(va.va_rdev) == &sequencer_cdevsw) {
+ vp->v_type == VCHR) {
+ vn_lock(vp, LK_SHARED | LK_RETRY);
+ error = VOP_GETATTR(vp, &va, l->l_cred);
+ VOP_UNLOCK(vp);
+ if (error == 0 &&
+ cdevsw_lookup(va.va_rdev) == &sequencer_cdevsw)
+ is_sequencer = true;
+ }
+ if (is_sequencer) {
error = oss_ioctl_sequencer(l, (const void *)LINUX_TO_OSS(uap),
retval);
}
diff -r 31cd9eac5fd6 -r b6781a885c39 sys/compat/linux/common/linux_misc.c
--- a/sys/compat/linux/common/linux_misc.c Thu Oct 13 23:42:06 2011 +0000
+++ b/sys/compat/linux/common/linux_misc.c Fri Oct 14 09:23:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_misc.c,v 1.218 2010/11/02 18:18:07 chs Exp $ */
+/* $NetBSD: linux_misc.c,v 1.219 2011/10/14 09:23:28 hannken Exp $ */
/*-
* Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.218 2010/11/02 18:18:07 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.219 2011/10/14 09:23:28 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -696,7 +696,10 @@
goto out1;
}
- if ((error = VOP_GETATTR(vp, &va, l->l_cred)))
+ vn_lock(vp, LK_SHARED | LK_RETRY);
+ error = VOP_GETATTR(vp, &va, l->l_cred);
+ VOP_UNLOCK(vp);
+ if (error)
goto out1;
nbytes = SCARG(uap, count);
diff -r 31cd9eac5fd6 -r b6781a885c39 sys/compat/linux32/common/linux32_dirent.c
--- a/sys/compat/linux32/common/linux32_dirent.c Thu Oct 13 23:42:06 2011 +0000
+++ b/sys/compat/linux32/common/linux32_dirent.c Fri Oct 14 09:23:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux32_dirent.c,v 1.12 2010/09/11 20:53:04 chs Exp $ */
+/* $NetBSD: linux32_dirent.c,v 1.13 2011/10/14 09:23:29 hannken Exp $ */
/*-
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux32_dirent.c,v 1.12 2010/09/11 20:53:04 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_dirent.c,v 1.13 2011/10/14 09:23:29 hannken Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -130,7 +130,10 @@
goto out1;
}
- if ((error = VOP_GETATTR(vp, &va, l->l_cred)))
+ vn_lock(vp, LK_SHARED | LK_RETRY);
+ error = VOP_GETATTR(vp, &va, l->l_cred);
+ VOP_UNLOCK(vp);
+ if (error)
goto out1;
nbytes = SCARG(uap, count);
diff -r 31cd9eac5fd6 -r b6781a885c39 sys/compat/ossaudio/ossaudio.c
--- a/sys/compat/ossaudio/ossaudio.c Thu Oct 13 23:42:06 2011 +0000
+++ b/sys/compat/ossaudio/ossaudio.c Fri Oct 14 09:23:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ossaudio.c,v 1.66 2011/09/06 01:19:34 jmcneill Exp $ */
+/* $NetBSD: ossaudio.c,v 1.67 2011/10/14 09:23:29 hannken Exp $ */
/*-
* Copyright (c) 1997, 2008 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.66 2011/09/06 01:19:34 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.67 2011/10/14 09:23:29 hannken Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -935,7 +935,7 @@
struct vattr va;
static struct audiodevinfo devcache;
struct audiodevinfo *di = &devcache;
- int mlen, dlen;
+ int error, mlen, dlen;
/*
* Figure out what device it is so we can check if the
@@ -944,7 +944,10 @@
vp = fp->f_data;
if (vp->v_type != VCHR)
return 0;
- if (VOP_GETATTR(vp, &va, kauth_cred_get()))
+ vn_lock(vp, LK_SHARED | LK_RETRY);
+ error = VOP_GETATTR(vp, &va, kauth_cred_get());
+ VOP_UNLOCK(vp);
+ if (error)
return 0;
if (di->done && di->dev == va.va_rdev)
return di;
diff -r 31cd9eac5fd6 -r b6781a885c39 sys/compat/svr4/svr4_fcntl.c
--- a/sys/compat/svr4/svr4_fcntl.c Thu Oct 13 23:42:06 2011 +0000
+++ b/sys/compat/svr4/svr4_fcntl.c Fri Oct 14 09:23:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: svr4_fcntl.c,v 1.70 2008/04/28 20:23:45 martin Exp $ */
+/* $NetBSD: svr4_fcntl.c,v 1.71 2011/10/14 09:23:29 hannken Exp $ */
/*-
* Copyright (c) 1994, 1997, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svr4_fcntl.c,v 1.70 2008/04/28 20:23:45 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_fcntl.c,v 1.71 2011/10/14 09:23:29 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -263,7 +263,10 @@
fd_putfile(fd);
return ESPIPE;
}
- if ((error = VOP_GETATTR(vp, &vattr, l->l_cred)) != 0) {
+ vn_lock(vp, LK_SHARED | LK_RETRY);
+ error = VOP_GETATTR(vp, &vattr, l->l_cred);
+ VOP_UNLOCK(vp);
+ if (error) {
fd_putfile(fd);
return error;
}
diff -r 31cd9eac5fd6 -r b6781a885c39 sys/compat/svr4_32/svr4_32_fcntl.c
--- a/sys/compat/svr4_32/svr4_32_fcntl.c Thu Oct 13 23:42:06 2011 +0000
+++ b/sys/compat/svr4_32/svr4_32_fcntl.c Fri Oct 14 09:23:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: svr4_32_fcntl.c,v 1.34 2008/04/28 20:23:46 martin Exp $ */
+/* $NetBSD: svr4_32_fcntl.c,v 1.35 2011/10/14 09:23:29 hannken Exp $ */
/*-
* Copyright (c) 1994, 1997, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svr4_32_fcntl.c,v 1.34 2008/04/28 20:23:46 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_32_fcntl.c,v 1.35 2011/10/14 09:23:29 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -261,7 +261,10 @@
fd_putfile(fd);
return ESPIPE;
}
- if ((error = VOP_GETATTR(vp, &vattr, l->l_cred)) != 0) {
+ vn_lock(vp, LK_SHARED | LK_RETRY);
+ error = VOP_GETATTR(vp, &vattr, l->l_cred);
+ VOP_UNLOCK(vp);
+ if (error) {
fd_putfile(fd);
return error;
}
diff -r 31cd9eac5fd6 -r b6781a885c39 sys/dev/ccd.c
--- a/sys/dev/ccd.c Thu Oct 13 23:42:06 2011 +0000
+++ b/sys/dev/ccd.c Fri Oct 14 09:23:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ccd.c,v 1.141 2011/07/04 16:06:45 joerg Exp $ */
+/* $NetBSD: ccd.c,v 1.142 2011/10/14 09:23:29 hannken Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -88,7 +88,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.141 2011/07/04 16:06:45 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.142 2011/10/14 09:23:29 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -310,7 +310,10 @@
/*
* XXX: Cache the component's dev_t.
*/
- if ((error = VOP_GETATTR(vpp[ix], &va, l->l_cred)) != 0) {
+ vn_lock(vpp[ix], LK_SHARED | LK_RETRY);
+ error = VOP_GETATTR(vpp[ix], &va, l->l_cred);
+ VOP_UNLOCK(vpp[ix]);
+ if (error != 0) {
#ifdef DEBUG
if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
printf("%s: %s: getattr failed %s = %d\n",
diff -r 31cd9eac5fd6 -r b6781a885c39 sys/dev/cgd.c
--- a/sys/dev/cgd.c Thu Oct 13 23:42:06 2011 +0000
+++ b/sys/dev/cgd.c Fri Oct 14 09:23:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.74 2011/06/21 06:23:38 jruoho Exp $ */
+/* $NetBSD: cgd.c,v 1.75 2011/10/14 09:23:30 hannken Exp $ */
/*-
Home |
Main Index |
Thread Index |
Old Index