On Tue, Apr 16, 2019 at 4:04 PM Guenter Roeck <gro...@google.com> wrote:
>
> On Tue, Apr 16, 2019 at 1:37 PM Dan Williams <dan.j.willi...@intel.com> wrote:
> > Ah, no, the problem is that jump_label_init() is called by
> > setup_arch() on x86, and smp_prepare_boot_cpu() on powerpc, but not
> > until after parse_args() on ARM.
> >
> Anywhere but arm64, x86, and ppc, really.
>
> $ git grep jump_label_init arch
> arch/arm64/kernel/smp.c:        jump_label_init();
> arch/powerpc/lib/feature-fixups.c:      jump_label_init();
> arch/x86/kernel/setup.c:        jump_label_init();

Oooh, nice. Yeah, so, this is already a bug for "hardened_usercopy=0"
which sets static branches too.

> > Given it appears to be safe to call jump_label_init() early how about
> > something like the following?
> >
> > diff --git a/init/main.c b/init/main.c
> > index 598e278b46f7..7d4025d665eb 100644
> > --- a/init/main.c
> > +++ b/init/main.c
> > @@ -582,6 +582,8 @@ asmlinkage __visible void __init start_kernel(void)
> >         page_alloc_init();
> >
> >         pr_notice("Kernel command line: %s\n", boot_command_line);
> > +       /* parameters may set static keys */
> > +       jump_label_init();
> >         parse_early_param();
> >         after_dashes = parse_args("Booting kernel",
> >                                   static_command_line, __start___param,
> > @@ -591,8 +593,6 @@ asmlinkage __visible void __init start_kernel(void)
> >                 parse_args("Setting init args", after_dashes, NULL, 0, -1, 
> > -1,
> >                            NULL, set_init_arg);
> >
> > -       jump_label_init();
> > -
>
> That should work, unless there was a reason to have it that late. It
> doesn't look like that was the case, but I may be missing something.

Yes please. :) Let's fix it like you've suggested.

Reviewed-by: Kees Cook <keesc...@chromium.org>

-- 
Kees Cook

Reply via email to