Re: [PATCH] mm/memblock: fix overlapping allocation when doublingreserved array

From: Yinghai Lu
Date: Fri Jun 15 2012 - 18:39:09 EST


On Fri, Jun 15, 2012 at 2:09 PM, Greg Pearson <greg.pearson@xxxxxx> wrote:
> The __alloc_memory_core_early() routine will ask memblock for a range
> of memory then try to reserve it. If the reserved region array lacks
> space for the new range, memblock_double_array() is called to allocate
> more space for the array. If memblock is used to allocate memory for
> the new array it can end up using a range that overlaps with the range
> originally allocated in __alloc_memory_core_early(), leading to possible
> data corruption.
>
> @@ -399,7 +401,8 @@ repeat:
>         */
>        if (!insert) {
>                while (type->cnt + nr_new > type->max)
> -                       if (memblock_double_array(type) < 0)
> +                       /* Avoid possible overlap if range is being reserved */
> +                       if (memblock_double_array(type, base) < 0)

should use obase here.

Yinghai

>                                return -ENOMEM;
>                insert = true;
>                goto repeat;
--
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/