Skip to contentSkip to conversation

FDPIC: Add coredump capability for the ELF-FDPIC binfmt [try #4]

PATCH Oleg Nesterov 2 participants 3 messages Jul 9, 2006 – Jul 11, 2006

lore
Share & tools
lore
#0 lore raw
Quoted 11 lines · David Howells
(quoted diff) +7 -0
+static int elf_fdpic_core_dump(long signr, struct pt_regs *regs,
+			       struct file *file)
+{
 
[... snip ...]
 
+		read_lock(&tasklist_lock);
+		do_each_thread(g,p)
+			if (current->mm == p->mm && current != p) {
+				tmp = kzalloc(sizeof(*tmp), GFP_ATOMIC);

Review

Quoted 10 lines
(quoted diff) +10 -0
+				if (!tmp) {
+					read_unlock(&tasklist_lock);
+					goto cleanup;
+				}
+				INIT_LIST_HEAD(&tmp->list);
+				tmp->thread = p;
+				list_add(&tmp->list, &thread_list);
+			}
+		while_each_thread(g,p);
+		read_unlock(&tasklist_lock);

Do you see any reason for tasklist_lock here (and in elf_core_dump) ?

do_each_thread() is rcu-safe, and all tasks which use this ->mm must sleep in wait_for_completion(&mm->core_done) at this point.

Oleg.

#1 lore raw
Quoted 4 lines · Oleg Nesterov

Do you see any reason for tasklist_lock here (and in elf_core_dump) ?

do_each_thread() is rcu-safe, and all tasks which use this ->mm must sleep in wait_for_completion(&mm->core_done) at this point.

Hmmm... do_each_thread() does not call rcu_read_lock/unlock(), but you may well be right. What about kernel threads running on another CPU with active_mm set to this mm (assuming I'm remembering correctly how that works)? I'm not sure they'd be a problem, though.

It does sound like you've got a valid point, though.

David

#2 lore raw
Quoted 10 lines · David Howells
Quoted 4 lines · Oleg Nesterov

Do you see any reason for tasklist_lock here (and in elf_core_dump) ?

do_each_thread() is rcu-safe, and all tasks which use this ->mm must sleep in wait_for_completion(&mm->core_done) at this point.

Hmmm... do_each_thread() does not call rcu_read_lock/unlock(), but you may well be right.

Yes, we can't just kill tasklist_lock, we should replace it with rcu_read_lock.

Quoted 3 lines

What about kernel threads running on another CPU with
active_mm set to this mm (assuming I'm remembering correctly how that works)? I'm not sure they'd be a problem, though.

Those threads have ->mm == NULL, this loop will not count them. But I think tasklist_lock can't make any difference for this issue. I am not sure I understand your concern, it is ok to use this ->mm (current uses it), and a kernel thread incremented ->mm_count.

Oleg.