@@ -339,17 +339,23 @@ static struct pid **task_pid_ptr(struct task_struct *task, enum pid_type type)
339
339
*/
340
340
void attach_pid (struct task_struct * task , enum pid_type type )
341
341
{
342
- struct pid * pid = * task_pid_ptr (task , type );
342
+ struct pid * pid ;
343
+
344
+ lockdep_assert_held_write (& tasklist_lock );
345
+
346
+ pid = * task_pid_ptr (task , type );
343
347
hlist_add_head_rcu (& task -> pid_links [type ], & pid -> tasks [type ]);
344
348
}
345
349
346
350
static void __change_pid (struct task_struct * task , enum pid_type type ,
347
351
struct pid * new )
348
352
{
349
- struct pid * * pid_ptr = task_pid_ptr (task , type );
350
- struct pid * pid ;
353
+ struct pid * * pid_ptr , * pid ;
351
354
int tmp ;
352
355
356
+ lockdep_assert_held_write (& tasklist_lock );
357
+
358
+ pid_ptr = task_pid_ptr (task , type );
353
359
pid = * pid_ptr ;
354
360
355
361
hlist_del_rcu (& task -> pid_links [type ]);
@@ -386,6 +392,8 @@ void exchange_tids(struct task_struct *left, struct task_struct *right)
386
392
struct hlist_head * head1 = & pid1 -> tasks [PIDTYPE_PID ];
387
393
struct hlist_head * head2 = & pid2 -> tasks [PIDTYPE_PID ];
388
394
395
+ lockdep_assert_held_write (& tasklist_lock );
396
+
389
397
/* Swap the single entry tid lists */
390
398
hlists_swap_heads_rcu (head1 , head2 );
391
399
@@ -403,6 +411,7 @@ void transfer_pid(struct task_struct *old, struct task_struct *new,
403
411
enum pid_type type )
404
412
{
405
413
WARN_ON_ONCE (type == PIDTYPE_PID );
414
+ lockdep_assert_held_write (& tasklist_lock );
406
415
hlist_replace_rcu (& old -> pid_links [type ], & new -> pid_links [type ]);
407
416
}
408
417
0 commit comments