Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3815190ybl; Mon, 13 Jan 2020 03:09:04 -0800 (PST) X-Google-Smtp-Source: APXvYqy3fBX/jcC3kom72Mn1KJg7280waOJo5AKb/yx6Hv1dfbWYqn6Wc0q6bdWtlAZci0hq1xNa X-Received: by 2002:aca:5905:: with SMTP id n5mr12597881oib.54.1578913744412; Mon, 13 Jan 2020 03:09:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578913744; cv=none; d=google.com; s=arc-20160816; b=fR/NGoEML8wuPL2omxeTeWJqsXNryHZQ+TQb4LvJ2Iy/H9J/sS3wx0kGQnbuxyZGoK FsUkUxXUUmHu8oOmT7PIZipDDcDtKpUrdpq7Z3g2kAFANwRbc0CKBYw6BmFH1if5/Bcq HwalwVLJKk4yV2qUC71XiJFXZxW45+tAv5/DLiyqXlq4lfw4LeSoqY9+HWvUXeYSi7wD +5HZboWV4fXLk+mqAPPuQVS/+gMyRR2yU+m9OIaMql3p6LMO/IiXq756OGQ+fUqaNZY6 6oz/xA/Jh3vj1lliyeW+josycHfHSM39x0sL7n+Af4dnoyTpcJyYQL8TS4AagryMzjog +X2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=78ja8/5CuvSLqZCvuuXdsPK/mvMU480ty7qFtDJrhMM=; b=EovJHnQShxHmhTWom3jIo7HD7VDHOb55MHOnaiChYuxN5Bv9CILP2uiLyaAYN3JDDq SE6VoSe3iJPRSYOdaA3Kcs9Q7adFBZ4fYDAhRPfTw2fHyZeeOkFMxsbmW1wxSsv+oIC1 S1zSvdddbAGWjlkG4tYM1VLPPKk8fv42nBcuW7jfP8g80sJPpaj7AiEmI+/Tm+5aJYK2 Qe2xpo81sFyAYjF2s6aqDNVDkHK6jro1G1xa0Q8jZuYY7dsUR/AX7WLwbsAjct0Yz7me Lr87X+jkvIt4P46e/P2dk06WAi3QJG5P3nSIyLkPKPPwSZ/W6zuE+cEw2BQM4syfFf95 YadQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h7si6170682otm.165.2020.01.13.03.08.52; Mon, 13 Jan 2020 03:09:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728709AbgAMLHo (ORCPT + 99 others); Mon, 13 Jan 2020 06:07:44 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:49513 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726193AbgAMLHn (ORCPT ); Mon, 13 Jan 2020 06:07:43 -0500 Received: from 79.184.255.90.ipv4.supernova.orange.pl (79.184.255.90) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.320) id c7ad015d3098e161; Mon, 13 Jan 2020 12:07:40 +0100 From: "Rafael J. Wysocki" To: Johannes Stezenbach , Alexander Potapenko , "Acked-by: Kees Cook" , "Acked-by: Michal Hocko" Cc: linux-pm@vger.kernel.org, Andrew Morton , LKML Subject: Re: init_on_free breaks hibernate Date: Mon, 13 Jan 2020 12:07:40 +0100 Message-ID: <2661668.lOhekKA4Va@kreacher> In-Reply-To: <20200113092604.GA26365@sig21.net> References: <20191223211309.GA4609@sig21.net> <20200113092604.GA26365@sig21.net> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >