]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
mm/execmem: make the populate and alloc atomic
authorHubert Mazur <hmazur@google.com>
Fri, 20 Mar 2026 07:57:23 +0000 (07:57 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 5 Apr 2026 20:53:34 +0000 (13:53 -0700)
commit1871d548fc4feb007644efb6d669c93a4e191254
tree090cc7ad181f9506505341580f0ea3b9619b627f
parent6f1e1823875f59591df1159b7d193b40337ef524
mm/execmem: make the populate and alloc atomic

When a block of memory is requested from the execmem manager it tries to
find a suitable fragment by traversing the free_areas.  In case there is
no such block, a new memory area is added to the free_areas and then
allocated to the caller by traversing the free_area tree again.

The above operations of allocation and tree traversal are not atomic hence
another request may consume this newly allocated memory block which
results in the allocation failure for the original request.  Such
occurrence can be spotted on devices running the 6.18 kernel during the
parallel modules loading.

To mitigate such resource races execute the cache population and
allocation operations under one mutex lock.

Link: https://lkml.kernel.org/r/20260320075723.779985-1-hmazur@google.com
Signed-off-by: Hubert Mazur <hmazur@google.com>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Stanislaw Kardach <skardach@google.com>
Cc: Michal Krawczyk <mikrawczyk@google.com>
Cc: Slawomir Rosek <srosek@google.com>
Cc: Hubert Mazur <hmazur@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/execmem.c