Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-doc
Path: blob/main/website/static/security/patches/EN-08:01/libpthread.patch
18096 views
1
Index: lib/libpthread/sys/lock.c
2
===================================================================
3
RCS file: /home/ncvs/src/lib/libpthread/sys/Attic/lock.c,v
4
retrieving revision 1.9.2.1
5
diff -u -r1.9.2.1 lock.c
6
--- lib/libpthread/sys/lock.c 5 Aug 2005 19:43:56 -0000 1.9.2.1
7
+++ lib/libpthread/sys/lock.c 12 Mar 2008 19:18:47 -0000
8
@@ -117,14 +117,23 @@
9
{
10
if (lu == NULL)
11
return (-1);
12
- /*
13
- * All lockusers keep their watch request and drop their
14
- * own (lu_myreq) request. Their own request is either
15
- * some other lockuser's watch request or is the head of
16
- * the lock.
17
- */
18
- lu->lu_myreq = lu->lu_watchreq;
19
- if (lu->lu_myreq == NULL)
20
+
21
+ if (lu->lu_watchreq != NULL) {
22
+ /*
23
+ * In this case the lock is active. All lockusers
24
+ * keep their watch request and drop their own
25
+ * (lu_myreq) request. Their own request is either
26
+ * some other lockuser's watch request or is the
27
+ * head of the lock.
28
+ */
29
+ lu->lu_myreq = lu->lu_watchreq;
30
+ lu->lu_watchreq = NULL;
31
+ }
32
+ if (lu->lu_myreq == NULL)
33
+ /*
34
+ * Oops, something isn't quite right. Try to
35
+ * allocate one.
36
+ */
37
return (_lockuser_init(lu, priv));
38
else {
39
lu->lu_myreq->lr_locked = 1;
40
Index: lib/libpthread/thread/thr_kern.c
41
===================================================================
42
RCS file: /home/ncvs/src/lib/libpthread/thread/Attic/thr_kern.c,v
43
retrieving revision 1.116.2.1
44
diff -u -r1.116.2.1 thr_kern.c
45
--- lib/libpthread/thread/thr_kern.c 16 Mar 2006 23:29:07 -0000 1.116.2.1
46
+++ lib/libpthread/thread/thr_kern.c 12 Mar 2008 19:19:05 -0000
47
@@ -345,6 +345,17 @@
48
_LCK_SET_PRIVATE2(&curthread->kse->k_lockusers[i], NULL);
49
}
50
curthread->kse->k_locklevel = 0;
51
+
52
+ /*
53
+ * Reinitialize the thread and signal locks so that
54
+ * sigaction() will work after a fork().
55
+ */
56
+ _lock_reinit(&curthread->lock, LCK_ADAPTIVE, _thr_lock_wait,
57
+ _thr_lock_wakeup);
58
+ _lock_reinit(&_thread_signal_lock, LCK_ADAPTIVE, _kse_lock_wait,
59
+ _kse_lock_wakeup);
60
+
61
+
62
_thr_spinlock_init();
63
if (__isthreaded) {
64
_thr_rtld_fini();
65
@@ -354,6 +365,20 @@
66
curthread->kse->k_kcb->kcb_kmbx.km_curthread = NULL;
67
curthread->attr.flags |= PTHREAD_SCOPE_SYSTEM;
68
69
+ /*
70
+ * After a fork, it is possible that an upcall occurs in
71
+ * the parent KSE that fork()'d before the child process
72
+ * is fully created and before its vm space is copied.
73
+ * During the upcall, the tcb is set to null or to another
74
+ * thread, and this is what gets copied in the child process
75
+ * when the vm space is cloned sometime after the upcall
76
+ * occurs. Note that we shouldn't have to set the kcb, but
77
+ * we do it for completeness.
78
+ */
79
+ _kcb_set(curthread->kse->k_kcb);
80
+ _tcb_set(curthread->kse->k_kcb, curthread->tcb);
81
+
82
+
83
/* After a fork(), there child should have no pending signals. */
84
sigemptyset(&curthread->sigpend);
85
86
87