Re: commit 444d13ff10f introduced boot failure on s390x

From: Heiko Carstens
Date: Tue Aug 16 2016 - 02:48:47 EST


On Mon, Aug 15, 2016 at 03:12:53PM -0400, Jessica Yu wrote:
> +++ Jessica Yu [10/08/16 18:58 -0400]:
> >+++ Eryu Guan [10/08/16 23:21 +0800]:
> >>Hi,
> >>
> >>I hit boot failure on s390x host starting from 4.8-rc1 kernel, 4.7
> >>kernel works fine. And I bisected to this commit 444d13ff10fb
> >>
> >> commit 444d13ff10fb13bc3e64859c3cf9ce43dcfeb075
> >> Author: Jessica Yu <jeyu@xxxxxxxxxx>
> >> Date: Wed Jul 27 12:06:21 2016 +0930
> >>
> >> modules: add ro_after_init support
> >>
> >> Add ro_after_init support for modules by adding a new page-aligned section
> >> in the module layout (after rodata) for ro_after_init data and enabling RO
> >> protection for that section after module init runs.
> >>
> >> Signed-off-by: Jessica Yu <jeyu@xxxxxxxxxx>
> >> Acked-by: Kees Cook <keescook@xxxxxxxxxxxx>
> >> Signed-off-by: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
> >>
> >>and I've only hit this panic on s390x hosts. Console log is appended at
> >>the end of email.
> >>
> >>Thanks,
> >>Eryu
> >
> >Hi Eryu, thanks for reporting this. It's a bit difficult to tell from
> >the stacktrace alone what's really going on, so I'll attempt to
> >reproduce this on a 4.8-rc1 kernel once I get my hands on an s390x
> >system and report back.
>
> [ CC'ing Heiko and Martin ]
>
> So this panic is related to some recent changes to set_memory_{ro,rw}
> on s390x, see commit e8a97e42 "s390/pageattr: allow kernel page table
> splitting." The new implementation of set_memory_{ro,rw} on s390 isn't
> handling the case when numpages is 0.
>
> Recall the general layout of a module:
> [text] [rodata] [ro-after-init] [writable data]
>
> Normally a module's ro after init section sits between rodata and
> writable data. When a module doesn't have a ro after init section,
> set_memory_ro gets called with the first page-aligned addr after
> rodata, but with numpages = 0. However in this case since
> set_memory_ro isn't handling the case when numpages is 0, it
> incorrectly ends up walking the page table anyway and ends up setting
> a normally writable page to ro. Adding a simple numpages == 0 check
> to set_memory_{ro,rw} and returning fixes the panic.
>
> Jessica

All what you write is correct. The patch below is sitting in our "fixes"
branch since a week:

https://git.kernel.org/cgit/linux/kernel/git/s390/linux.git/log/?h=fixes

I assume there will be a pull request from Martin soon.