Thread (27 messages) 27 messages, 6 authors, 2024-10-24

Re: [PATCH v6 4/8] module: prepare to handle ROX allocations for text

From: Luis Chamberlain <mcgrof@kernel.org>
Date: 2024-10-19 22:30:44
Also in: bpf, linux-alpha, linux-arch, linux-m68k, linux-mips, linux-mm, linux-modules, linux-riscv, linux-sh, linux-um, linuxppc-dev, lkml, loongarch, sparclinux

On Wed, Oct 16, 2024 at 03:24:20PM +0300, Mike Rapoport wrote:
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>

In order to support ROX allocations for module text, it is necessary to
handle modifications to the code, such as relocations and alternatives
patching, without write access to that memory.

One option is to use text patching, but this would make module loading
extremely slow and will expose executable code that is not finally formed.

A better way is to have memory allocated with ROX permissions contain
invalid instructions and keep a writable, but not executable copy of the
module text. The relocations and alternative patches would be done on the
writable copy using the addresses of the ROX memory.
Once the module is completely ready, the updated text will be copied to ROX
memory using text patching in one go and the writable copy will be freed.

Add support for that to module initialization code and provide necessary
interfaces in execmem.

Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Reviewd-by: Luis Chamberlain [off-list ref]

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