linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Sang-Heon Jeon <ekffu200098@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Jonathan Corbet <corbet@lwn.net>, Jason Gunthorpe <jgg@ziepe.ca>,
	linux-doc@vger.kernel.org, linux-mm@kvack.org,
	Pratyush Yadav <pratyush@kernel.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Kees Cook <kees@kernel.org>
Subject: Re: [PATCH v2] memblock: reject non-page-aligned reserve_mem regions
Date: Tue, 8 Sep 2026 09:48:57 +0300	[thread overview]
Message-ID: <ap-v2XUH2Usov_RK@kernel.org> (raw)
In-Reply-To: <20260905141526.1546478-1-ekffu200098@gmail.com>

(adding tracing and pstore folks)

On Sat, Sep 05, 2026 at 11:15:24PM +0900, Sang-Heon Jeon wrote:
> When map->start or map->size is not page aligned,
> reserved_mem_preserve() does not preserve the last one or two pages of
> the region from map->start to map->start + map->size.
> 
> After kexec the new kernel reserves only the preserved pages, so those
> pages are released to the buddy allocator. But
> reserve_mem_find_by_name() still returns the whole region including
> them, so they can be allocated while the subsystem is still using them.
> 
> So reject a reserve_mem= size or alignment that is not a multiple of
> PAGE_SIZE to keep both map->start and map->size page aligned.
> 
> Fixes: 8375b76517cb ("kho: replace kho_preserve_phys() with kho_preserve_pages()")
> Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
> ---
> Changes from v1 [1]
> - reject non-page-aligned size and align instead of fix page count when
>   preserving reserve_mem regions
> 
> [1] https://lore.kernel.org/all/20260901165237.1025973-1-ekffu200098@gmail.com/
> ---
>  Documentation/admin-guide/kernel-parameters.txt | 3 +++
>  mm/memblock.c                                   | 9 +++++++--
>  2 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 68647ff4bdd2..f969085fffb7 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -6648,6 +6648,9 @@ Kernel parameters
>  
>  			reserve_mem=12M:4096:oops ramoops.mem_name=oops
>  
> +			Both the size and the alignment must be multiples of
> +			the page size.
> +
>  	reservetop=	[X86-32,EARLY]
>  			Format: nn[KMG]
>  			Reserves a hole at the top of the kernel virtual
> diff --git a/mm/memblock.c b/mm/memblock.c
> index 4302fb4ab85c..5e93b6da53e3 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -2816,12 +2816,17 @@ static int __init reserve_mem(char *p)
>  	if (*p != ':')
>  		goto err_param;
>  
> +	if (!IS_ALIGNED(size, PAGE_SIZE) || !IS_ALIGNED(align, PAGE_SIZE)) {
> +		pr_err("reserve_mem: size and align must be multiples of the page size\n");
> +		return -EINVAL;
> +	}
> +
>  	/*
>  	 * memblock_phys_alloc() doesn't like a zero size align,
>  	 * but it is OK for this command to have it.
>  	 */
> -	if (align < SMP_CACHE_BYTES)
> -		align = SMP_CACHE_BYTES;
> +	if (!align)
> +		align = PAGE_SIZE;
>  
>  	name = p + 1;
>  	len = strlen(name);
> 
> base-commit: dbffc67777cd752ef3f77818109e1d2ef13e2949
> -- 
> 2.43.0
> 

-- 
Sincerely yours,
Mike.

      reply	other threads:[~2026-09-08  6:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-05 14:15 [PATCH v2] memblock: reject non-page-aligned reserve_mem regions Sang-Heon Jeon
2026-09-08  6:48 ` Mike Rapoport [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=ap-v2XUH2Usov_RK@kernel.org \
    --to=rppt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=ekffu200098@gmail.com \
    --cc=jgg@ziepe.ca \
    --cc=kees@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhiramat@kernel.org \
    --cc=pratyush@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=skhan@linuxfoundation.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).