Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1730476

Re: nios2 crash due to 'init/main.c: extract early boot entropy from the passed cmdline'

From Kees Cook <keescook@chromium.org>
Newsgroups linux.kernel
Subject Re: nios2 crash due to 'init/main.c: extract early boot entropy from the passed cmdline'
Date 2017-09-11 20:50 +0200
Message-ID <uoBWp-75f-7@gated-at.bofh.it> (permalink)
References <uo1zz-6wn-3@gated-at.bofh.it> <uozUC-5Qs-15@gated-at.bofh.it> <uoAQF-6s2-15@gated-at.bofh.it> <uoBD4-6YB-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Sep 11, 2017 at 11:25 AM, Daniel Micay <danielmicay@gmail.com> wrote:
> On Mon, 2017-09-11 at 10:35 -0700, Guenter Roeck wrote:
>> On Mon, Sep 11, 2017 at 09:36:00AM -0700, Kees Cook wrote:
>> > On Sat, Sep 9, 2017 at 8:58 PM, Guenter Roeck <linux@roeck-us.net>
>> > wrote:
>> > > Hi,
>> > >
>> > > I noticed that nios2 images crash in mainline. Bisect points to
>> > > commit
>> > > 33d72f3822d7 ("init/main.c: extract early boot entropy from the
>> > > passed
>> > > cmdline").  Bisect log is attached.
>> > >
>> > > As far as I can see, the problem is seen because
>> > > add_device_randomness()
>> > > calls random_get_entropy(). However, the underlying timer function
>> > > used by the nios2 architecture (nios2_timer_read) is not yet
>> > > initialized,
>> > > causing a NULL pointer access and crash. A sample crash log is at
>> > >         http://kerneltests.org/builders/qemu-nios2-master/builds/1
>> > > 75/steps/qemubuildcommand/logs/stdio
>> >
>> > Oh, yikes. Do you have a full call trace? (Does this come through
>> > get_cycles() or via the It seems like we could either initialize the
>> > timer earlier or allow it to fall back when not initialized...
>> >
>>
>> nios2 doesn't give me a traceback. I followed it by adding debug
>> messages.
>> The code path is through get_cycles().
>>
>> On nios2:
>>
>> static u64 nios2_timer_read(struct clocksource *cs)
>> {
>>       struct nios2_clocksource *nios2_cs = to_nios2_clksource(cs);
>>       unsigned long flags;
>>       u32 count;
>>
>>       local_irq_save(flags);
>>       count = read_timersnapshot(&nios2_cs->timer);   // <- not
>> initialized
>>       local_irq_restore(flags);
>>
>>       /* Counter is counting down */
>>       return ~count;
>> }
>>
>> cycles_t get_cycles(void)
>> {
>>         return nios2_timer_read(&nios2_cs.cs);
>> }
>> EXPORT_SYMBOL(get_cycles);
>>
>> Guenter
>
> Maybe it should WARN and return 0 for now if that's NULL?

In this case, we'd always WARN. :P But yeah, 0 return on NULL timer
seems okay to me here. I am curious if it's possible to start the
timer earlier, though. It's not clear to me where nios2_cs->timer gets
set.

-Kees

-- 
Kees Cook
Pixel Security

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

nios2 crash due to 'init/main.c: extract early boot entropy from the  passed cmdline' Guenter Roeck <linux@roeck-us.net> - 2017-09-10 06:00 +0200
  Re: nios2 crash due to 'init/main.c: extract early boot entropy from  the passed cmdline' Kees Cook <keescook@chromium.org> - 2017-09-11 18:40 +0200
    Re: nios2 crash due to 'init/main.c: extract early boot entropy from  the passed cmdline' Guenter Roeck <linux@roeck-us.net> - 2017-09-11 19:40 +0200
      Re: nios2 crash due to 'init/main.c: extract early boot entropy  from the passed cmdline' Daniel Micay <danielmicay@gmail.com> - 2017-09-11 20:30 +0200
        Re: nios2 crash due to 'init/main.c: extract early boot entropy from  the passed cmdline' Kees Cook <keescook@chromium.org> - 2017-09-11 20:50 +0200
          Re: nios2 crash due to 'init/main.c: extract early boot entropy from  the passed cmdline' Laura Abbott <labbott@redhat.com> - 2017-09-11 21:10 +0200

csiph-web