summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2018-06-04 04:46:07 +0000
committerguenther <guenther@openbsd.org>2018-06-04 04:46:07 +0000
commit3bc9e445d10d08c0183fa7992e5cbdd3641ef899 (patch)
treeecb00beb04e50f082770a52c0ce49338d59ad812
parentUse variable names for rtable and rdomain consistently in the in_pcb (diff)
downloadwireguard-openbsd-3bc9e445d10d08c0183fa7992e5cbdd3641ef899.tar.xz
wireguard-openbsd-3bc9e445d10d08c0183fa7992e5cbdd3641ef899.zip
Add RW_DUPOK for suppressing witness checks for specific rw_enter() calls
ok deraadt@ visa@
-rw-r--r--share/man/man9/rwlock.910
-rw-r--r--sys/kern/kern_rwlock.c4
-rw-r--r--sys/sys/rwlock.h3
3 files changed, 13 insertions, 4 deletions
diff --git a/share/man/man9/rwlock.9 b/share/man/man9/rwlock.9
index 8270a938c97..9b7276926e3 100644
--- a/share/man/man9/rwlock.9
+++ b/share/man/man9/rwlock.9
@@ -1,4 +1,4 @@
-.\" $OpenBSD: rwlock.9,v 1.20 2017/10/30 13:33:36 visa Exp $
+.\" $OpenBSD: rwlock.9,v 1.21 2018/06/04 04:46:08 guenther Exp $
.\"
.\" Copyright (c) 2006 Pedro Martelletto <pedro@ambientworks.net>
.\" All rights reserved.
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: October 30 2017 $
+.Dd $Mdocdate: June 4 2018 $
.Dt RWLOCK 9
.Os
.Sh NAME
@@ -149,6 +149,12 @@ instead.
Wait for busy locks, but do not obtain them, fail with
.Dv EAGAIN
instead.
+.It Dv RW_DUPOK
+Prevents
+.Xr witness 4 ,
+for just this
+.Fn rw_enter ,
+from logging when this thread already has more than one lock of this lock type.
.El
.Pp
The
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c
index d24bb6c8734..97e22a5e966 100644
--- a/sys/kern/kern_rwlock.c
+++ b/sys/kern/kern_rwlock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_rwlock.c,v 1.35 2018/03/21 12:28:39 bluhm Exp $ */
+/* $OpenBSD: kern_rwlock.c,v 1.36 2018/06/04 04:46:07 guenther Exp $ */
/*
* Copyright (c) 2002, 2003 Artur Grabowski <art@openbsd.org>
@@ -223,6 +223,8 @@ _rw_enter(struct rwlock *rwl, int flags LOCK_FL_VARS)
lop_flags = LOP_NEWORDER;
if (flags & RW_WRITE)
lop_flags |= LOP_EXCLUSIVE;
+ if (flags & RW_DUPOK)
+ lop_flags |= LOP_DUPOK;
if ((flags & RW_NOSLEEP) == 0 && (flags & RW_DOWNGRADE) == 0)
WITNESS_CHECKORDER(&rwl->rwl_lock_obj, lop_flags, file, line,
NULL);
diff --git a/sys/sys/rwlock.h b/sys/sys/rwlock.h
index 8b6808cec53..740ea3be1d6 100644
--- a/sys/sys/rwlock.h
+++ b/sys/sys/rwlock.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rwlock.h,v 1.22 2017/08/12 23:27:44 guenther Exp $ */
+/* $OpenBSD: rwlock.h,v 1.23 2018/06/04 04:46:07 guenther Exp $ */
/*
* Copyright (c) 2002 Artur Grabowski <art@openbsd.org>
*
@@ -116,6 +116,7 @@ struct rwlock {
#define RW_SLEEPFAIL 0x0020UL /* fail if we slept for the lock */
#define RW_NOSLEEP 0x0040UL /* don't wait for the lock */
#define RW_RECURSEFAIL 0x0080UL /* Fail on recursion for RRW locks. */
+#define RW_DUPOK 0x0100UL /* Permit duplicate lock */
/*
* for rw_status() and rrw_status() only: exclusive lock held by