Commit 1ca50d7
committed
fix(task): fix fork heap inheritance and child_tid handling
Bug 1 - Fork not inheriting heap pointers:
After fork, child's heap_bottom/heap_top were reset to USER_HEAP_BASE
instead of inheriting parent's heap state, causing brk() to fail.
Fix: Copy heap pointers from parent to child in fork path.
Bug 2 - set_child_tid/clear_child_tid NULL pointer issues:
When CLONE_CHILD_SETTID or CLONE_CHILD_CLEARTID flags were set but
child_tid was NULL, kernel would access invalid memory.
Fix: Check address is non-NULL before processing, pass as usize,
write using aspace.write() in child's context.
Bug 3 - execve not clearing clear_child_tid:
After execve, clear_child_tid from old address space remained set,
causing invalid memory access on process exit.
Fix: Clear clear_child_tid after execve.1 parent 97d7c9d commit 1ca50d7
3 files changed
+60
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
131 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
132 | 134 | | |
133 | 135 | | |
134 | 136 | | |
| |||
182 | 184 | | |
183 | 185 | | |
184 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
185 | 190 | | |
186 | 191 | | |
187 | 192 | | |
| |||
215 | 220 | | |
216 | 221 | | |
217 | 222 | | |
218 | | - | |
| 223 | + | |
219 | 224 | | |
220 | 225 | | |
221 | 226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
68 | 71 | | |
69 | 72 | | |
70 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
39 | 49 | | |
40 | | - | |
| 50 | + | |
41 | 51 | | |
42 | 52 | | |
43 | 53 | | |
| |||
164 | 174 | | |
165 | 175 | | |
166 | 176 | | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
174 | 195 | | |
175 | | - | |
176 | 196 | | |
177 | 197 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
182 | 202 | | |
183 | 203 | | |
184 | 204 | | |
| |||
213 | 233 | | |
214 | 234 | | |
215 | 235 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
220 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
221 | 248 | | |
222 | 249 | | |
223 | 250 | | |
| |||
0 commit comments