public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: init_on_free breaks hibernate
       [not found] ` <20200113092604.GA26365@sig21.net>
@ 2020-01-13 11:07   ` Rafael J. Wysocki
  2020-01-13 13:42     ` Alexander Potapenko
  0 siblings, 1 reply; 2+ messages in thread
From: Rafael J. Wysocki @ 2020-01-13 11:07 UTC (permalink / raw)
  To: Johannes Stezenbach, Alexander Potapenko, Acked-by: Kees Cook,
	Acked-by: Michal Hocko
  Cc: linux-pm, Andrew Morton, LKML

On Monday, January 13, 2020 10:26:04 AM CET Johannes Stezenbach wrote:
> Hi,
> 
> On Mon, Dec 23, 2019 at 10:13:09PM +0100, Johannes Stezenbach wrote:
> > I upgraded the kernel on one of my machines to 5.3.18 (from 5.2.x)
> > and found it failed after resume from hibernate due to what seemed
> > to be memory corruption. I had a hunch it could be related to
> > CONFIG_INIT_ON_ALLOC_DEFAULT_ON or CONFIG_INIT_ON_FREE_DEFAULT_ON,
> > and a quick web search found this which seems to confirm:
> > https://bbs.archlinux.org/viewtopic.php?pid=1877845#p1877845
> > 
> > I rebuilt the kernel with CONFIG_INIT_ON_FREE_DEFAULT_ON disabled,
> > and hibernate works again.  I'm fine with this workaround and
> > just wanted to share this information.
> > 
> > The commit that introduces CONFIG_INIT_ON_FREE_DEFAULT_ON:
> > 6471384af2a6 mm: security: introduce init_on_alloc=1 and init_on_free=1 boot options
> 
> I tested 5.4.11 and current git master (b07f636fca1c8)
> in Qemu and was able to reproduce the issue in both.

Let's add more people and the LKML to the CC.

Alex, Kees, Michal, any comments?

> Basically I followed the description here
> http://ncmiller.github.io/2016/05/14/linux-and-qemu.html
> to build a minimal image using busybox (I'm using
> the binary from Debian's busybox-static package),
> then added s swap image (-drive file=disk.img,if=virtio),
> do "mkswap /dev/vda" the first time.
> 
> hibernate: swapon /dev/vda; echo disk >/sys/power/state
> resume: echo 254:0 >/sys/power/resume
> 
> Since busybox is very light on memory usage it doesn't
> trigger immediately, but these commands seem to do it
> reliably:
> 
>   dmesg | gzip >/dev/null
>   find /sys | bzip2 | sha512sum
> 
> 
> my initramfs:
>   6012997      4 drwxr-xr-x   4 js       js           4096 Jan  8 21:25 initramfs
>   6022584      4 drwxr-xr-x   2 js       js           4096 Jan  8 21:21 initramfs/dev
>   5909013      4 -rwxr-xr-x   1 js       js            514 Jan  8 21:25 initramfs/init
>   6012998      4 drwxr-xr-x   2 js       js           4096 Jan  8 20:41 initramfs/bin
>   5909011   1904 -rwxr-xr-x   1 js       js        1945856 Apr  1  2019 initramfs/bin/busybox
>   5909012      0 lrwxrwxrwx   1 js       js              7 Feb 14  2018 initramfs/bin/sh -> busybox
> 
> my /init:
> #!/bin/sh
> 
> PATH=/bin
> export PATH
> 
> # Create dirs
> /bin/busybox mkdir -p /proc /sys /etc /tmp /usr
> /bin/busybox ln -s /bin /sbin
> /bin/busybox ln -s /bin /usr/bin
> /bin/busybox ln -s /bin /usr/sbin
> # Create all the symlinks to busybox
> /bin/busybox --install -s
> 
> mount -t proc proc /proc
> mount -t sysfs sysfs /sys
> mount -t devtmpfs devtmpfs /dev
> 
> echo -e "\nBoot took $(cut -d' ' -f1 /proc/uptime) seconds\n"
> 
> # shell where ^C works
> setsid busybox cttyhack sh
> # avoid "PID 1 exited" oops
> poweroff -f
> ---------
> 
> 
> qemu-system-x86_64 -m 128 -enable-kvm \
>   -kernel ../linux/arch/x86/boot/bzImage \
>   -initrd initramfs.cpio \
>   -drive file=disk.img,if=virtio \
>   -nographic -append "console=ttyS0 init_on_alloc=1 init_on_free=1"
> 
> 
> Johannes
> 





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: init_on_free breaks hibernate
  2020-01-13 11:07   ` init_on_free breaks hibernate Rafael J. Wysocki
@ 2020-01-13 13:42     ` Alexander Potapenko
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Potapenko @ 2020-01-13 13:42 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Johannes Stezenbach, Acked-by: Kees Cook, Acked-by: Michal Hocko,
	linux-pm, Andrew Morton, LKML

On Mon, Jan 13, 2020 at 12:07 PM Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
>
> On Monday, January 13, 2020 10:26:04 AM CET Johannes Stezenbach wrote:
> > Hi,
> >
> > On Mon, Dec 23, 2019 at 10:13:09PM +0100, Johannes Stezenbach wrote:
> > > I upgraded the kernel on one of my machines to 5.3.18 (from 5.2.x)
> > > and found it failed after resume from hibernate due to what seemed
> > > to be memory corruption. I had a hunch it could be related to
> > > CONFIG_INIT_ON_ALLOC_DEFAULT_ON or CONFIG_INIT_ON_FREE_DEFAULT_ON,
> > > and a quick web search found this which seems to confirm:
> > > https://bbs.archlinux.org/viewtopic.php?pid=1877845#p1877845
> > >
> > > I rebuilt the kernel with CONFIG_INIT_ON_FREE_DEFAULT_ON disabled,
> > > and hibernate works again.  I'm fine with this workaround and
> > > just wanted to share this information.
> > >
> > > The commit that introduces CONFIG_INIT_ON_FREE_DEFAULT_ON:
> > > 6471384af2a6 mm: security: introduce init_on_alloc=1 and init_on_free=1 boot options
> >
> > I tested 5.4.11 and current git master (b07f636fca1c8)
> > in Qemu and was able to reproduce the issue in both.
>
> Let's add more people and the LKML to the CC.
>
> Alex, Kees, Michal, any comments?
Hm, I cannot think of a reason for initialization to break hibernate
off the top of my head.
Maybe after hibernation certain pages land in the page freelist
without being wiped?
I'll try to reproduce this problem locally.

> > Basically I followed the description here
> > http://ncmiller.github.io/2016/05/14/linux-and-qemu.html
> > to build a minimal image using busybox (I'm using
> > the binary from Debian's busybox-static package),
> > then added s swap image (-drive file=disk.img,if=virtio),
> > do "mkswap /dev/vda" the first time.
> >
> > hibernate: swapon /dev/vda; echo disk >/sys/power/state
> > resume: echo 254:0 >/sys/power/resume
> >
> > Since busybox is very light on memory usage it doesn't
> > trigger immediately, but these commands seem to do it
> > reliably:
> >
> >   dmesg | gzip >/dev/null
> >   find /sys | bzip2 | sha512sum
> >
> >
> > my initramfs:
> >   6012997      4 drwxr-xr-x   4 js       js           4096 Jan  8 21:25 initramfs
> >   6022584      4 drwxr-xr-x   2 js       js           4096 Jan  8 21:21 initramfs/dev
> >   5909013      4 -rwxr-xr-x   1 js       js            514 Jan  8 21:25 initramfs/init
> >   6012998      4 drwxr-xr-x   2 js       js           4096 Jan  8 20:41 initramfs/bin
> >   5909011   1904 -rwxr-xr-x   1 js       js        1945856 Apr  1  2019 initramfs/bin/busybox
> >   5909012      0 lrwxrwxrwx   1 js       js              7 Feb 14  2018 initramfs/bin/sh -> busybox
> >
> > my /init:
> > #!/bin/sh
> >
> > PATH=/bin
> > export PATH
> >
> > # Create dirs
> > /bin/busybox mkdir -p /proc /sys /etc /tmp /usr
> > /bin/busybox ln -s /bin /sbin
> > /bin/busybox ln -s /bin /usr/bin
> > /bin/busybox ln -s /bin /usr/sbin
> > # Create all the symlinks to busybox
> > /bin/busybox --install -s
> >
> > mount -t proc proc /proc
> > mount -t sysfs sysfs /sys
> > mount -t devtmpfs devtmpfs /dev
> >
> > echo -e "\nBoot took $(cut -d' ' -f1 /proc/uptime) seconds\n"
> >
> > # shell where ^C works
> > setsid busybox cttyhack sh
> > # avoid "PID 1 exited" oops
> > poweroff -f
> > ---------
> >
> >
> > qemu-system-x86_64 -m 128 -enable-kvm \
> >   -kernel ../linux/arch/x86/boot/bzImage \
> >   -initrd initramfs.cpio \
> >   -drive file=disk.img,if=virtio \
> >   -nographic -append "console=ttyS0 init_on_alloc=1 init_on_free=1"
> >
> >
> > Johannes
> >
>
>
>
>


-- 
Alexander Potapenko
Software Engineer

Google Germany GmbH
Erika-Mann-Straße, 33
80636 München

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-13 13:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20191223211309.GA4609@sig21.net>
     [not found] ` <20200113092604.GA26365@sig21.net>
2020-01-13 11:07   ` init_on_free breaks hibernate Rafael J. Wysocki
2020-01-13 13:42     ` Alexander Potapenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox