Thread (52 messages) 52 messages, 11 authors, 2024-04-22

Re: [PATCH v4 05/15] mm: introduce execmem_alloc() and execmem_free()

From: Song Liu <song@kernel.org>
Date: 2024-04-19 17:32:52
Also in: bpf, linux-arch, linux-arm-kernel, linux-mips, linux-mm, linux-modules, linux-riscv, linux-s390, linux-trace-kernel, lkml, loongarch, netdev, sparclinux

On Fri, Apr 19, 2024 at 10:03 AM Mike Rapoport [off-list ref] wrote:
[...]
quoted
quoted
[1] https://lore.kernel.org/all/20240411160526.2093408-1-rppt@kernel.org (local)
For the ROX to work, we need different users (module text, kprobe, etc.) to have
the same execmem_range. From [1]:

static void *execmem_cache_alloc(struct execmem_range *range, size_t size)
{
...
       p = __execmem_cache_alloc(size);
       if (p)
               return p;
      err = execmem_cache_populate(range, size);
...
}

We are calling __execmem_cache_alloc() without range. For this to work,
we can only call execmem_cache_alloc() with one execmem_range.
Actually, on x86 this will "just work" because everything shares the same
address space :)

The 2M pages in the cache will be in the modules space, so
__execmem_cache_alloc() will always return memory from that address space.

For other architectures this indeed needs to be fixed with passing the
range to __execmem_cache_alloc() and limiting search in the cache for that
range.
I think we at least need the "map to" concept (initially proposed by Thomas)
to get this work. For example, EXECMEM_BPF and EXECMEM_KPROBE
maps to EXECMEM_MODULE_TEXT, so that all these actually share
the same range.

Does this make sense?

Song
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help