Re: [PATCH v3 6/9] module: switch to execmem API for remapping as RW and restoring ROX

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 27, 2025 at 01:50:31PM +0100, Petr Pavlu wrote:
> On 1/26/25 08:47, Mike Rapoport wrote:
> > From: "Mike Rapoport (Microsoft)" <rppt@xxxxxxxxxx>
> > 
> > Instead of using writable copy for module text sections, temporarily remap
> > the memory allocated from execmem's ROX cache as writable and restore its
> > ROX permissions after the module is formed.
> > 
> > This will allow removing nasty games with writable copy in alternatives
> > patching on x86.
> > 
> > Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
> 
> [...]
> 
> > +static void module_memory_restore_rox(struct module *mod)
> > +{
> > +	for_class_mod_mem_type(type, text) {
> > +		struct module_memory *mem = &mod->mem[type];
> > +
> > +		if (mem->is_rox)
> > +			execmem_restore_rox(mem->base, mem->size);
> > +	}
> > +}
> > +
> 
> Can the execmem_restore_rox() call here fail? I realize that there isn't
> much that the module loader can do if that happens, but should it be
> perhaps logged as a warning?

It won't fail at this point. set_memory APIs may fail if they need to split
a large page and could not allocate a new page table, but here all the
splits were already done at module_memory_alloc() time.
 
> -- 
> Thanks,
> Petr

-- 
Sincerely yours,
Mike.




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux Kernel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux