Re: [PATCH v3 02/11] mm: Hardened usercopy

From: Balbir Singh
Date: Wed Jul 20 2016 - 06:24:19 EST


On Tue, 2016-07-19 at 11:48 -0700, Kees Cook wrote:
> On Mon, Jul 18, 2016 at 6:06 PM, Laura Abbott <labbott@xxxxxxxxxx> wrote:
>
> > On 07/15/2016 02:44 PM, Kees Cook wrote:
>
> > This doesn't work when copying CMA allocated memory since CMA purposely
> > allocates larger than a page block size without setting head pages.
> > Given CMA may be used with drivers doing zero copy buffers, I think it
> > should be permitted.
>
> > Something like the following lets it pass (I can clean up and submit
> > the is_migrate_cma_page APIs as a separate patch for review)
> Yeah, this would be great. I'd rather use an accessor to check this
> than a direct check for MIGRATE_CMA.
>
> > ÂÂÂÂÂÂÂÂÂ*/
> > ÂÂÂÂÂÂÂÂfor (; ptr <= end ; ptr += PAGE_SIZE, page = virt_to_head_page(ptr))
> > {
> > -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (!PageReserved(page))
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (!PageReserved(page) && !is_migrate_cma_page(page))
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂreturn "<spans multiple pages>";
> > ÂÂÂÂÂÂÂÂ}
> Yeah, I'll modify this a bit so that which type it starts as is
> maintained for all pages (rather than allowing to flip back and forth
> -- even though that is likely impossible).
>Â
Sorry, I completely missed the MIGRATE_CMA bits. Could you clarify if you
caught this in testing/review?

Balbir Singh.