linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Kees Cook <keescook@chromium.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [RFC][PATCH] lkdtm/usercopy: Add tests for other memory types
Date: Thu, 12 May 2022 19:56:13 +0100	[thread overview]
Message-ID: <Yn1YTZkWVWfXk5Q8@casper.infradead.org> (raw)
In-Reply-To: <20220512183613.1069697-1-keescook@chromium.org>

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.

  reply	other threads:[~2022-05-12 18:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-12 18:36 [RFC][PATCH] lkdtm/usercopy: Add tests for other memory types Kees Cook
2022-05-12 18:56 ` Matthew Wilcox [this message]
2022-05-12 19:12   ` Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yn1YTZkWVWfXk5Q8@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).