summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkettenis <>2014-07-11 09:51:37 +0000
committerkettenis <>2014-07-11 09:51:37 +0000
commit25a3a3ed30f4daae2b1c6770e720788a87237895 (patch)
tree94c42169c276a400046c9eb3aa5902d44db4dcb6 /src
parent965351763a132661c6089be7d931cfc18d8c6e80 (diff)
downloadopenbsd-25a3a3ed30f4daae2b1c6770e720788a87237895.tar.gz
openbsd-25a3a3ed30f4daae2b1c6770e720788a87237895.tar.bz2
openbsd-25a3a3ed30f4daae2b1c6770e720788a87237895.zip
Add locking for __cxa_finalize() as it modifies the page permissions of the
__atexit tables and touches global variables. From Srinavasa Nagaraju through Android/Elliott Hughes. ok tedu@, guenther@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/stdlib/atexit.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/libc/stdlib/atexit.c b/src/lib/libc/stdlib/atexit.c
index 34f76bb7d3..6532b382ea 100644
--- a/src/lib/libc/stdlib/atexit.c
+++ b/src/lib/libc/stdlib/atexit.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: atexit.c,v 1.19 2014/07/10 21:14:22 tedu Exp $ */ 1/* $OpenBSD: atexit.c,v 1.20 2014/07/11 09:51:37 kettenis Exp $ */
2/* 2/*
3 * Copyright (c) 2002 Daniel Hartmeier 3 * Copyright (c) 2002 Daniel Hartmeier
4 * All rights reserved. 4 * All rights reserved.
@@ -116,6 +116,7 @@ __cxa_finalize(void *dso)
116 int n, pgsize = getpagesize(); 116 int n, pgsize = getpagesize();
117 static int call_depth; 117 static int call_depth;
118 118
119 _ATEXIT_LOCK();
119 call_depth++; 120 call_depth++;
120 121
121restart: 122restart:
@@ -136,7 +137,9 @@ restart:
136 p->fns[n].fn_ptr = NULL; 137 p->fns[n].fn_ptr = NULL;
137 mprotect(p, pgsize, PROT_READ); 138 mprotect(p, pgsize, PROT_READ);
138 } 139 }
140 _ATEXIT_UNLOCK();
139 (*fn.fn_ptr)(fn.fn_arg); 141 (*fn.fn_ptr)(fn.fn_arg);
142 _ATEXIT_LOCK();
140 if (restartloop) 143 if (restartloop)
141 goto restart; 144 goto restart;
142 } 145 }
@@ -157,6 +160,7 @@ restart:
157 } 160 }
158 __atexit = NULL; 161 __atexit = NULL;
159 } 162 }
163 _ATEXIT_UNLOCK();
160} 164}
161 165
162/* 166/*