Re: [RFC][PATCH] fix move/migrate_pages() race on task struct

From: Dave Hansen
Date: Fri Feb 24 2012 - 16:38:54 EST


On 02/24/2012 09:32 AM, Christoph Lameter wrote:
> @@ -1318,10 +1318,10 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pi
> rcu_read_lock();
> task = pid ? find_task_by_vpid(pid) : current;
> if (!task) {
> - rcu_read_unlock();
> err = -ESRCH;
> goto out;
> }
...
> + put_task_struct(task);
> + task = NULL;
> err = do_migrate_pages(mm, old, new,
> capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
> out:
> + if (task)
> + put_task_struct(task);
> +
> if (mm)
> mmput(mm);
> NODEMASK_SCRATCH_FREE(scratch);

Man, patch did not like this for some reason. I kept throwing most of
the mempolicy.c hunks away. I've never seen anything like it.

Anyway... This looks fine except I think that rcu_read_unlock() need to
stay. There's currently no release of it after out:.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/