Re: [PATCH v2 6/9] s390/module: Use s390_kernel_write() for late relocations

Josh Poimboeuf
2020-04-24T13:43:01Z

On Wed, Apr 22, 2020 at 02:28:26PM +0200, Miroslav Benes wrote:
> > +int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
> > + unsigned int symindex, unsigned int relsec,
> > + struct module *me)
> > +{
> > + int ret;
> > + bool early = me->state == MODULE_STATE_UNFORMED;
> > + void *(*write)(void *, const void *, size_t) = memcpy;
> > +
> > + if (!early) {
> > + write = s390_kernel_write;
> > + mutex_lock(&text_mutex);
> > + }
> > +
> > + ret = __apply_relocate_add(sechdrs, strtab, symindex, relsec, me,
> > + write);
> > +
> > + if (!early)
> > + mutex_unlock(&text_mutex);
> > +
> > + return ret;
> > +}
>
> It means that you can take text_mutex the second time here because it
> is still taken in klp_init_object_loaded(). It is removed later in the
> series though. The same applies for x86 patch.
>
> Also, s390_kernel_write() grabs s390_kernel_write_lock spinlock before
> writing anything, so maybe text_mutex is not really needed as long as
> s390_kernel_write is called everywhere for text patching.

Good catch, maybe I'll just drop the text_mutex here.

--
Josh