All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hao Ge <hao.ge@linux.dev>
To: Suren Baghdasaryan <surenb@google.com>
Cc: david@kernel.org, liam@infradead.org, vbabka@kernel.org,
	hannes@cmpxchg.org, brendan.jackman@linux.dev, ziy@nvidia.com,
	bigeasy@linutronix.de, clrkwllms@kernel.org, rostedt@goodmis.org,
	pasha.tatashin@soleen.com, pyyjason@gmail.com,
	usamaarif642@gmail.com, linux-mm@kvack.org,
	linux-rt-devel@lists.linux.dev, akpm@linux-foundation.org
Subject: Re: [PATCH 1/3] alloc_tag: preserve the error when reserving a module tag area fails
Date: Fri, 4 Dec 2026 15:47:20 +0800	[thread overview]
Message-ID: <b2e448be-b6c0-44b1-8e98-5fc10020a65a@linux.dev> (raw)
In-Reply-To: <20261204015630.4095988-2-surenb@google.com>



On 2026/12/4 09:56, Suren Baghdasaryan wrote:
> When storing the module area fails after the padding in front of it was
> stored, reserve_module_tags() removes the padding with mas_erase() and
> only then reads the error from the maple state. mas_erase() walks the
> tree and overrides the error stored in mas.node, therefore the correct
> error code gets cleared and later treated as area reservation success.
> This leaves the same memory area available for allocation to subsequent
> modules, causing silent memory corruption of allocation tags.
> 
> Store the error before removing the padding.
> 
> Fixes: 0db6f8d7820a ("alloc_tag: load module tags into separate contiguous memory")
> Closes: https://sashiko.dev/#/bug/linux-64e7eab3-9791-43b6-a55e-fc05f931983c
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>

Reviewed-by: Hao Ge <hao.ge@linux.dev>

> ---
>  mm/alloc_tag.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/alloc_tag.c b/mm/alloc_tag.c
> index 18bec85b6220..b4e55bbf57f6 100644
> --- a/mm/alloc_tag.c
> +++ b/mm/alloc_tag.c
> @@ -1010,9 +1010,10 @@ static void *reserve_module_tags(struct module *mod, unsigned long size,
>  		mas.last = offset + size - 1;
>  		mas_store(&mas, mod);
>  		if (mas_is_err(&mas)) {
> +			/* mas_erase() resets the error in the maple state */
> +			ret = ERR_PTR(xa_err(mas.node));
>  			mas.index = pad_start;
>  			mas_erase(&mas);
> -			ret = ERR_PTR(xa_err(mas.node));
>  		}
>  	} else {
>  		mas.last = offset + size - 1;


  parent reply	other threads:[~2026-12-04  7:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  1:56 [PATCH 0/3] alloc_tag: fixes for module tag area handling and the show_mem() report Suren Baghdasaryan
2026-12-04  1:56 ` [PATCH 1/3] alloc_tag: preserve the error when reserving a module tag area fails Suren Baghdasaryan
2026-12-04  2:06   ` Liam R. Howlett
2026-12-04  7:47   ` Hao Ge [this message]
2026-12-04  1:56 ` [PATCH 2/3] alloc_tag: do not leak module tag areas when removing them fails Suren Baghdasaryan
2026-12-04  2:29   ` Liam R. Howlett
2026-12-04 18:31     ` Suren Baghdasaryan
2026-12-04  1:56 ` [PATCH 3/3] mm/show_mem: avoid unsafe locking when reporting allocation profiling Suren Baghdasaryan
2026-12-04  2:48   ` Liam R. Howlett
2026-12-04 18:44     ` Suren Baghdasaryan

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=b2e448be-b6c0-44b1-8e98-5fc10020a65a@linux.dev \
    --to=hao.ge@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=bigeasy@linutronix.de \
    --cc=brendan.jackman@linux.dev \
    --cc=clrkwllms@kernel.org \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=liam@infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=pasha.tatashin@soleen.com \
    --cc=pyyjason@gmail.com \
    --cc=rostedt@goodmis.org \
    --cc=surenb@google.com \
    --cc=usamaarif642@gmail.com \
    --cc=vbabka@kernel.org \
    --cc=ziy@nvidia.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.