Commit 931292f
committed
misc/user: use lockless update for user_creds structure
Using a reference count on user_creds structure avoids having to hold
the process's lock when reading its content. Instead, the accesser
uses a kind of RCU mechanism to only read the credentials at the time
the function was called.
This makes the code much cleaner, and avoids potentially blocking
other process operations.
NOTE: Since everything is lockless now, this introduces a potential
TOCTOU error if 2 threads belonging to the same process call
the set[*]uid/gid() function at the same time. This does not
seem like a critical issue, but we may want to prevent reads
during update operations (true RCU).
Closes #721 parent 7ef398c commit 931292f
5 files changed
Lines changed: 316 additions & 182 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | | - | |
37 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
38 | 43 | | |
39 | 44 | | |
40 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| |||
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
| 165 | + | |
| 166 | + | |
164 | 167 | | |
165 | 168 | | |
166 | 169 | | |
167 | 170 | | |
168 | 171 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
178 | 179 | | |
| 180 | + | |
179 | 181 | | |
180 | 182 | | |
181 | 183 | | |
| |||
243 | 245 | | |
244 | 246 | | |
245 | 247 | | |
| 248 | + | |
246 | 249 | | |
247 | 250 | | |
248 | 251 | | |
| |||
251 | 254 | | |
252 | 255 | | |
253 | 256 | | |
254 | | - | |
| 257 | + | |
255 | 258 | | |
256 | 259 | | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
261 | 265 | | |
262 | 266 | | |
263 | 267 | | |
| |||
366 | 370 | | |
367 | 371 | | |
368 | 372 | | |
| 373 | + | |
369 | 374 | | |
370 | 375 | | |
371 | 376 | | |
372 | 377 | | |
373 | 378 | | |
374 | 379 | | |
375 | 380 | | |
| 381 | + | |
| 382 | + | |
376 | 383 | | |
377 | 384 | | |
| 385 | + | |
378 | 386 | | |
379 | 387 | | |
380 | | - | |
| 388 | + | |
381 | 389 | | |
382 | | - | |
| 390 | + | |
383 | 391 | | |
384 | 392 | | |
| 393 | + | |
385 | 394 | | |
386 | | - | |
| 395 | + | |
387 | 396 | | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
392 | 400 | | |
393 | 401 | | |
394 | 402 | | |
395 | | - | |
| 403 | + | |
396 | 404 | | |
397 | 405 | | |
398 | 406 | | |
399 | 407 | | |
400 | 408 | | |
401 | 409 | | |
| 410 | + | |
| 411 | + | |
402 | 412 | | |
403 | 413 | | |
404 | 414 | | |
| |||
0 commit comments