Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hao Ge" <hao.ge@linux.dev>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Uladzislau Rezki" <urezki@gmail.com>,
	"Dev Jain" <dev.jain@arm.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"David Hildenbrand (Arm)" <david@kernel.org>,
	"Madhavan Srinivasan" <maddy@linux.ibm.com>,
	"Michael Ellerman" <mpe@ellerman.id.au>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
	"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
	"Shrikanth Hegde" <sshegde@linux.ibm.com>,
	"Alexander Potapenko" <glider@google.com>,
	"Marco Elver" <elver@google.com>,
	"Dmitry Vyukov" <dvyukov@google.com>,
	"Dennis Zhou" <dennis@kernel.org>, "Tejun Heo" <tj@kernel.org>,
	"Christoph Lameter" <cl@gentwo.org>
Cc: kasan-dev@googlegroups.com, linux-mm@kvack.org
Subject: Re: [PATCH v6 07/10] mm/vmalloc: undo what a failed vmap_page_range() installed
Date: Thu, 03 Dec 2026 19:44:45 +0000	[thread overview]
Message-ID: <sashiko-outbox-248544@kernel.org> (raw)
In-Reply-To: <20261203092728.157806-8-hao.ge@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mm: vunmap_range_nokmsan() sends SMP IPIs despite
  atomic-context contract
--

commit a6c5a3931affbc3848f78bee8cb75dc56e46f428
Author: Hao Ge <hao.ge@linux.dev>

mm/vmalloc: undo what a failed vmap_page_range() installed

This commit tracks how far vmap_range_noflush() walked and introduces
vunmap_range_nokmsan() so vmap_page_range() can unmap partially
installed PTEs on walk or KMSAN failures.

> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 8540f20eb9b6b..7ac74a866408b 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c

[ ... ]

> @@ -552,6 +579,29 @@ void vunmap_range_noflush(unsigned long start, unsigned long end)
>  	__vunmap_range_noflush(start, end, true);
>  }
>  
> +/**
> + * vunmap_range_nokmsan - unmap kernel virtual addresses without the
> + * KMSAN part
> + * @addr: start of the VM area to unmap
> + * @end: end of the VM area to unmap (non-inclusive)
> + * @can_resched: whether the unmap walk may call cond_resched(); pass
> + * false from atomic context.
> + *
> + * Clears any present PTEs in the virtual address range, flushes TLBs and
> + * caches, but leaves the KMSAN metadata to the caller. The undo paths
> + * use this for a range that is not going back to vmalloc, which would
> + * flush the TLB lazily, so nobody else flushes it.
> + *
> + * This is an internal function only. Do not use outside mm/.
> + */
> +void vunmap_range_nokmsan(unsigned long addr, unsigned long end,
> +			  bool can_resched)
> +{
> +	flush_cache_vunmap(addr, end);
> +	__vunmap_range_noflush(addr, end, can_resched);
> +	flush_tlb_kernel_range(addr, end);
> +}

[Severity: Medium]
Is vunmap_range_nokmsan() actually safe to call from atomic context when
can_resched is false?

flush_tlb_kernel_range() (and flush_cache_vunmap() on PA-RISC) sends
synchronous IPIs via smp_call_function_many_cond() when there is no
hardware broadcast TLB invalidation.  That asserts IRQs are enabled and
in_task(), and can deadlock if two CPUs wait with IRQs disabled.

This commit only passes can_resched = true, but commit "mm/vmalloc: undo
what a failed __vmap_pages_range_noflush() installed" calls
vunmap_range_nokmsan(..., false) on GFP_ATOMIC vmalloc failures.

__get_vm_area_node() only rejects NMI, hardirq and softirq contexts, so
an IRQ-disabled task (e.g. a kprobe BPF program in
rhtab_map_update_elem() -> rhashtable_insert_rehash() falling back to
vmalloc) can reach this on a mid-walk page-table allocation failure.

Either defer cleanup for non-blocking contexts instead of issuing
synchronous IPI flushes, or reject IRQ-disabled contexts and document
that IRQs must be enabled.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203092728.157806-1-hao.ge@linux.dev?part=7


  reply	other threads:[~2026-12-03 19:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  9:27 [PATCH v6 00/10] mm/vmalloc: fix up vmap error handling Hao Ge
2026-12-03  9:27 ` [PATCH v6 01/10] mm/vmalloc: allow the vmap unmap paths to run in atomic context Hao Ge
2026-12-03 19:44   ` sashiko-bot
2026-12-03  9:27 ` [PATCH v6 02/10] mm/kmsan: undo the shadow mapping when the origin mapping fails Hao Ge
2026-12-03  9:27 ` [PATCH v6 03/10] mm/vmalloc: fix a typo in the __vunmap_range_noflush() comment Hao Ge
2026-12-03 19:44   ` sashiko-bot
2026-12-03  9:27 ` [PATCH v6 04/10] mm/kmsan: fix the metadata cache flush ordering Hao Ge
2026-12-03  9:27 ` [PATCH v6 05/10] mm/vmalloc: reject an unaligned range in vmap_page_range() Hao Ge
2026-12-03 19:44   ` sashiko-bot
2026-12-03  9:27 ` [PATCH v6 06/10] mm/vmalloc: reject an unaligned range in __vunmap_range_noflush() Hao Ge
2026-12-03  9:27 ` [PATCH v6 07/10] mm/vmalloc: undo what a failed vmap_page_range() installed Hao Ge
2026-12-03 19:44   ` sashiko-bot [this message]
2026-12-03  9:27 ` [PATCH v6 08/10] mm/vmalloc: undo what a failed __vmap_pages_range_noflush() installed Hao Ge
2026-12-03  9:27 ` [PATCH v6 09/10] powerpc: drop redundant unmaps of failed vmap mappings Hao Ge
2026-12-03  9:27 ` [PATCH v6 10/10] mm/percpu: stop unmapping the CPU that failed to map Hao Ge

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=sashiko-outbox-248544@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=chleroy@kernel.org \
    --cc=cl@gentwo.org \
    --cc=david@kernel.org \
    --cc=dennis@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=dvyukov@google.com \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=hao.ge@linux.dev \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-mm@kvack.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=ritesh.list@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sshegde@linux.ibm.com \
    --cc=surenb@google.com \
    --cc=tj@kernel.org \
    --cc=urezki@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox