lkml.org 
[lkml]   [2022]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH] lkdtm/usercopy: Add tests for other memory types
On Thu, May 12, 2022 at 11:36:13AM -0700, Kees Cook wrote:
> +static void lkdtm_USERCOPY_FOLIO(void)
> +{
> + struct folio *folio;
> + void *addr;
> +
> + /*
> + * FIXME: Folio checking currently misses 0-order allocations, so
> + * allocate and bump forward to the last page.
> + */
> + folio = folio_alloc(GFP_KERNEL | __GFP_ZERO, 1);
> + if (!folio) {
> + pr_err("folio_alloc() failed!?\n");
> + return;
> + }
> + addr = page_address(&folio->page);

Ideally, code shouldn't be using &folio->page. If it is, we have a
gap in the folio API. Fortunately, we have folio_address().

> + if (addr) {
> + do_usercopy_page_span("folio", addr + PAGE_SIZE);
> + }
> + folio_put(folio);
> +}

Other than that, this looks sane to me.

\
 
 \ /
  Last update: 2022-05-12 20:57    [W:0.052 / U:0.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site