Re: [PATCH] um: Fix to call read_initrd after init_bootmem
From: Masami Hiramatsu
Date: Thu Apr 27 2017 - 18:40:57 EST
On Fri, 28 Apr 2017 07:04:14 +0900
Masami Hiramatsu <mhiramat@xxxxxxxxxx> wrote:
> Hi Richard,
>
> On Thu, 27 Apr 2017 15:53:25 +0200
> Richard Weinberger <richard@xxxxxx> wrote:
>
> > Masami,
> >
> > Am 27.04.2017 um 05:15 schrieb Masami Hiramatsu:
> > > Since read_initrd() invokes alloc_bootmem() for allocating
> > > memory to load initrd image, it must be called after init_bootmem.
> > >
> > > This makes read_initrd() called directly from setup_arch()
> > > after init_bootmem() and mem_total_pages().
> >
> > Thanks for fixing this! Did you figure since when this is broken?
> > I think that should go into -stable.
>
> Thank you for quick response!
> As far as I can see, v4.9 kernel has this issue, but v4.4 is OK.
> Let me bisect it.
Finally, git bisect shows that below commit caused this issue.
b63236972e1344b247750451e2be0a06cd125f21 is the first bad commit
commit b63236972e1344b247750451e2be0a06cd125f21
Author: Richard Weinberger <richard@xxxxxx>
Date: Sun Jun 12 21:56:42 2016 +0200
um: Setup physical memory in setup_arch()
Currently UML sets up physical memory very early,
long before setup_arch() was called by the kernel main
function.
This can cause problems when code paths in UML's memory setup
code assume that the kernel is already running.
i.e. when kmemleak is enabled it will evaluate current()
in free_bootmem(). That early current() is undefined and
UML explodes.
Solve the problem by setting up physical memory in setup_arch(),
at this stage the kernel has materialized and basic infrastructure
such as current() works.
Signed-off-by: Richard Weinberger <richard@xxxxxx>
:040000 040000 94b9403e37b4d14b54f801198af71aed66b07a30 641f2309b7badd723f1996f141aad962255dd689 M arch
For the stable, any kernel later than v4.8 has this issue.
Thank you,
--
Masami Hiramatsu <mhiramat@xxxxxxxxxx>