Re: [PATCH 02/12] powerpc/module: Mark module stubs with a magic value

From: Michael Ellerman
Date: Thu Feb 25 2016 - 01:44:06 EST


On Thu, 2016-02-25 at 11:04 +1100, Balbir Singh wrote:
>
> On 25/02/16 01:28, Michael Ellerman wrote:
> > -bool is_module_trampoline(u32 *p)
> > +int module_trampoline_target(struct module *mod, unsigned long addr,
> > + unsigned long *target)
> > {
> > - unsigned int i;
> > - u32 insns[ARRAY_SIZE(ppc64_stub_insns)];
> > -
> > - BUILD_BUG_ON(sizeof(ppc64_stub_insns) != sizeof(ppc64_stub_mask));
> > + struct ppc64_stub_entry *stub;
> > + func_desc_t funcdata;
> > + u32 magic;
> >
> > - if (probe_kernel_read(insns, p, sizeof(insns)))
> > + if (!within_module_core(addr, mod)) {
> > + pr_err("%s: stub %lx not in module %s\n", __func__, addr, mod->name);
> > return -EFAULT;

> -EFAULT or -EINVAL?

I think we want EFAULT. Otherwise ftrace_bug() will try and print the actual
instruction, which would then fault. (though I haven't confirmed that by
testing)

> I wonder if we can recover from a bad trampoline address.

We can't recover at the moment. Do you mean is there some way we could recover?

cheers