Re: [PATCH RFC] kprobes: Remove MODULES dependency

From: Jarkko Sakkinen
Date: Mon Jul 13 2020 - 01:53:01 EST


On Fri, Jul 10, 2020 at 03:04:29PM +0200, Christoph Hellwig wrote:
> On Fri, Jul 10, 2020 at 01:32:38PM +0200, Peter Zijlstra wrote:
> > On Fri, Jul 10, 2020 at 07:32:57PM +0900, Masami Hiramatsu wrote:
> > > > - page = module_alloc(PAGE_SIZE);
> > > > + page = vmalloc(PAGE_SIZE);
> > >
> > > No, you can not use vmalloc here. The reason why we use module_alloc()
> > > is to allocate the executable memory for trampoline code.
> > > So, you need to use vmalloc_exec() instead.
> >
> > vmalloc_exec() would be broken too, also hch recently got rid of that
> > thing.
> >
> > module_alloc() really is the only sane choice here.
> >
> > We should make module_alloc() unconditionally available, and maybe even
> > rename it to text_alloc().
>
> I think unconitionally might be a bit too much, but for
> MODULES || KRPOBES or a new symbol select by them makes sense. As does
> the rename.

Given that they are simple wrappers, would it be too much harmo to have
inline functions for text_alloc() and text_memfree() and use them inside
module_alloc() and alloc_memfree() in order not to initially turn things
over too much?

/Jarkko