public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Matthew Wilcox <willy@infradead.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 12:12:02 -0700	[thread overview]
Message-ID: <202205121211.B7EFB5A@keescook> (raw)
In-Reply-To: <Yn1YTZkWVWfXk5Q8@casper.infradead.org>

On Thu, May 12, 2022 at 07:56:13PM +0100, Matthew Wilcox wrote:
> 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().

Ah! Perfect, thanks. In trying to find the right alloc/free pair I
missed folio_address() :)

-- 
Kees Cook

      reply	other threads:[~2022-05-12 19:12 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
2022-05-12 19:12   ` Kees Cook [this message]

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=202205121211.B7EFB5A@keescook \
    --to=keescook@chromium.org \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=willy@infradead.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