All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: David Laight <david.laight.linux@gmail.com>
Cc: Mahad Ibrahim <mahad.ibrahim.dev@gmail.com>,
	Kees Cook <kees@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lkdtm: use kmalloc() instead of __get_free_page
Date: Sun, 26 Jul 2026 10:06:01 +0300	[thread overview]
Message-ID: <amWx2QHfMHDeOuos@kernel.org> (raw)
In-Reply-To: <20260723094522.535b284c@pumpkin>

On Thu, Jul 23, 2026 at 09:45:22AM +0100, David Laight wrote:
> On Wed, 22 Jul 2026 23:02:46 +0000
> Mahad Ibrahim <mahad.ibrahim.dev@gmail.com> wrote:
> 
> > lkdtm_debugfs_entry and direct_entry use __get_free_page to allocate a
> > temporary buffer, perform copy_from_user to get the crashtype name,
> > strim() to strip whitespace and find_crashtype to find the corresponding
> > crashtype that is being requested.
> > 
> > The lkdtm_debugfs_read uses __get_free_page to allocate a temporary
> > buffer to store all the available crashtypes, and then copy it to
> > userspace.
> > 
> > The buffers that are allocated can be allocated with kmalloc as there is
> > nothing special that requires a struct page, or the page allocator.
> > 
> > kmalloc() additionally provides a better API that doesn't require ugly
> > casts which obfuscate the code and kfree does not need to know the size
> > of the freed object.
> > 
> > Replace use of __get_free_page() with kmalloc().
> 
> None of those buffers need to be PAGE_SIZE.
> Even the sanity limit for overlong requests could be 4k.
> The longest 'crashtype->name' is probably about 32 characters, so could
> probably go on stack.

As Arnd said, this is straightforward change, while changing actual
allocation size is more intrusive patch and you can send it if you think
it's worth the churn.
 
> And can't this code use the sysfs/kernfs wrappers?
> 
> 	David

-- 
Sincerely yours,
Mike.

  parent reply	other threads:[~2026-07-26  7:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 23:02 [PATCH] lkdtm: use kmalloc() instead of __get_free_page Mahad Ibrahim
2026-07-22 23:42 ` Mahad Ibrahim
2026-07-23  3:47   ` Kees Cook
2026-07-24  9:51     ` Mahad Ibrahim
2026-07-26  7:02     ` Mike Rapoport
2026-07-23  8:45 ` David Laight
2026-07-23  9:00   ` Arnd Bergmann
2026-07-24 10:29     ` Mahad Ibrahim
2026-07-26  7:06   ` Mike Rapoport [this message]
2026-07-26  7:03 ` Mike Rapoport

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=amWx2QHfMHDeOuos@kernel.org \
    --to=rppt@kernel.org \
    --cc=arnd@arndb.de \
    --cc=david.laight.linux@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mahad.ibrahim.dev@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.