Re: NULL-ptr deref in mmput via sys_migrate_pages in 3.4-rc4 (prolymissing mm==NULL check)

From: Robert ÅwiÄcki
Date: Tue Apr 24 2012 - 10:23:11 EST


On Tue, Apr 24, 2012 at 12:44 AM, Robert ÅwiÄcki <robert@xxxxxxxxxxx> wrote:
> mm/mempolicy.c
> 1362 Â Â Â Â mm = get_task_mm(task);
> 1363 Â Â Â Â put_task_struct(task);
> 1364 Â Â Â Â if (mm)
> 1365 Â Â Â Â Â Â Â Â err = do_migrate_pages(mm, old, new,
> 1366 Â Â Â Â Â Â Â Â Â Â Â Â capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL
> : MPOL_MF_MOVE);
> 1367 Â Â Â Â else
> 1368 Â Â Â Â Â Â Â Â err = -EINVAL;
> 1369
> 1370 Â Â Â Â mmput(mm);
>
> Where mmput doesn't check for mm
>
> kernel/fork.c
> 567 void mmput(struct mm_struct *mm)
> 568 {
> 569 Â Â Â Â might_sleep();
> 570
> 571 Â Â Â Â if (atomic_dec_and_test(&mm->mm_users)) {
>
>
> causes NULL-ptr deref
>
> (gdb) target remote /dev/ttyS0
> Remote debugging using /dev/ttyS0
> mmput (mm=0x0) at kernel/fork.c:571
> 571 Â Â Â Â Â Â if (atomic_dec_and_test(&mm->mm_users)) {
>
> (gdb) bt
> #0 Âmmput (mm=0x0) at kernel/fork.c:571
> #1 Â0xffffffff8116a1e0 in sys_migrate_pages (pid=<optimized out>,
> maxnode=<optimized out>, old_nodes=<optimized out>,
> new_nodes=<optimized out>) at mm/mempolicy.c:1370
> #2 Â0xffffffff820726c9 in ?? () at arch/x86/ia32/ia32entry.S:425
>
>
> (gdb) up
> #1 Â0xffffffff8116a1e0 in sys_migrate_pages (pid=<optimized out>,
> maxnode=<optimized out>, old_nodes=<optimized out>,
> new_nodes=<optimized out>) at mm/mempolicy.c:1370
> 1370 Â Â Â Â Â Âmmput(mm);
> (gdb) p mm
> $1 = (struct mm_struct *) 0x0
> (gdb) p task->mm
> $2 = (struct mm_struct *) 0x0

Most likely caused by this patch:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=3268c63eded4612a3d07b56d1e02ce7731e6608e

--
Robert ÅwiÄcki
--
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/