Skip to content

Commit

Permalink
11002 recursive mutex detection in libfakekernel
Browse files Browse the repository at this point in the history
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Approved by: Garrett D'Amore <garrett@damore.org>
  • Loading branch information
gwr committed Jun 6, 2019
1 parent 5831d79 commit a24b1e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion usr/src/lib/libfakekernel/common/mapfile-vers
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ SYMBOL_VERSION SUNWprivate_1.1 {
kmem_zalloc;

kmutex_destroy;
kmutex_init;
kmutex_enter;
kmutex_exit;
kmutex_init;

ksema_destroy;
ksema_init;
Expand Down
10 changes: 7 additions & 3 deletions usr/src/lib/libfakekernel/common/mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

/*
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
* Copyright 2018 Nexenta Systems, Inc. All rights reserved.
* Copyright 2017 RackTop Systems.
*/

Expand All @@ -31,8 +31,9 @@ int _lwp_mutex_trylock(lwp_mutex_t *);

extern clock_t ddi_get_lbolt(void);

/* See: head/synch.h ERRORCHECKMUTEX */
static const lwp_mutex_t default_mutex =
{{0, 0, 0, {USYNC_THREAD}, _MUTEX_MAGIC},
{{0, 0, 0, {USYNC_THREAD|LOCK_ERRORCHECK}, _MUTEX_MAGIC},
{{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0};

/* ARGSUSED */
Expand All @@ -53,8 +54,11 @@ kmutex_destroy(kmutex_t *mp)
void
kmutex_enter(kmutex_t *mp)
{
kthread_t *t = _curthread();

VERIFY(mp->m_owner != t);
VERIFY(0 == _lwp_mutex_lock(&mp->m_lock));
mp->m_owner = _curthread();
mp->m_owner = t;
}

int
Expand Down

0 comments on commit a24b1e6

Please sign in to comment.