public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
* [PATCH v1 0/1] Fix race condition in the memory management system
@ 2026-03-12 13:14 Hubert Mazur
  2026-03-12 13:14 ` [PATCH v1 1/1] mm: fix race condition in the memory management Hubert Mazur
  0 siblings, 1 reply; 4+ messages in thread
From: Hubert Mazur @ 2026-03-12 13:14 UTC (permalink / raw)
  To: Andrew Morton, Mike Rapoport
  Cc: Greg Kroah-Hartman, Stanislaw Kardach, Michal Krawczyk,
	Slawomir Rosek, Ryan Neph, linux-mm, linux-kernel, Hubert Mazur

When 'ARCH_HAS_EXECMEM_ROX' is being enabled the memory management
system will use caching techniques to optimize the allocations. The
logic tries to find the appropriate memory block based on requested
size. This can fail if current allocations is not sufficient hence
kernel allocates a new block large enough in regards to the request.
After the allocation is done, the new block is being added to the
free_areas tree and then - traverses the tree with hope to find the
matching piecie of memory. The operations of allocating new memory and
traversing the tree are not protected by mutex and thus there is a
chance that some other process will "steal" this shiny new block. It's a
classic race condition for resources. Fix this accordingly by moving a
new block of memory to busy fragments instead of free and return the
pointer to memory. This simplifies the allocation logic since we don't
firstly extend the free areas just to take it a bit later. In case the
new memory allocation is required - do it and return to the caller.

Hubert Mazur (1):
  mm: fix race condition in the memory management

 mm/execmem.c | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)

-- 
2.53.0.851.ga537e3e6e9-goog



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-12 15:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-12 13:14 [PATCH v1 0/1] Fix race condition in the memory management system Hubert Mazur
2026-03-12 13:14 ` [PATCH v1 1/1] mm: fix race condition in the memory management Hubert Mazur
2026-03-12 13:42   ` Mike Rapoport
2026-03-12 15:42     ` Hubert Mazur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox