From dc4b53247968c2ea07d8ccbafa8cd8c5eeaca0ff Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Tue, 4 Aug 2015 06:01:13 +0000 Subject: [PATCH] Fix bad arithmetic in umtx_key_get() to compute object offset. It looks like umtx_key_get() has the addition and subtraction the wrong way around, meaning that it fails to match in certain cases. This causes the cloudlibc unit tests to deadlock in certain cases. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D3287 --- sys/kern/kern_umtx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index cf472912164b..a40aa5a358c8 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -820,8 +820,8 @@ umtx_key_get(const void *addr, int type, int share, struct umtx_key *key) (share == AUTO_SHARE && VM_INHERIT_SHARE == entry->inheritance)) { key->shared = 1; - key->info.shared.offset = entry->offset + entry->start - - (vm_offset_t)addr; + key->info.shared.offset = (vm_offset_t)addr - + entry->start + entry->offset; vm_object_reference(key->info.shared.object); } else { key->shared = 0;