linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Askar Safin <safinaskar@gmail.com>
To: linux-pm@vger.kernel.org
Cc: "Rafael J. Wysocki" <rafael@kernel.org>, superm1@kernel.org
Subject: hibernate bug: "Image size after compression: -1210935 kbytes"
Date: Wed,  5 Nov 2025 21:05:03 +0300	[thread overview]
Message-ID: <20251105180506.137448-1-safinaskar@gmail.com> (raw)

I found hibernation bug: kernel sometimes reports negative size of
hibernation image.

Steps to reproduce:
- Your memory size should be 10000 MiB
- Your swap size should be 3000 MiB
- Mount ramfs
- Create 4000 MiB file with random (uncompressable) data in that ramfs
- Try to hibernate
- Of course, hibernation will fail, because you cannot fit 4000 MiB random file to
3000 MiB swap
- But you will see very strange message in kernel logs
"Image size after compression: -1210935 kbytes" (or similar)

Here is script for reproduction this bug in Qemu:
https://zerobin.net/?7d87d78855b41e07#yvP+T2c/v9A1AJr2d1tjWCbA6KUZZscDeESvbHqfqOo=

Here is resulting output (dmesg):
https://zerobin.net/?76c5a5e312ff7e6d#fH6jAkatrtRvtOWvFdo5EldWWP86wVxJrzzOCzvCQZc=

Reproducibility in Qemu: always (assuming you use script above).

The bug reproduces (in Qemu) on current master (284922f4c563).

I see two bugs in this output. First, negative size of hibernation image.
Second, "dmesg" doesn't contain any hibernation error. I. e. "dmesg" looks like
hibernation succeed, but it did not.

The bug is reproducible both in Qemu and on real hardware.
(Note: I reproduced it on real hardware with v6.12.48 kernel.)

This looks like integer overflow. I suggest double-checking that all
size calculations are 64-bit (on 64-bit systems) in hibernation code.

-- 
Askar Safin

                 reply	other threads:[~2025-11-05 18:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251105180506.137448-1-safinaskar@gmail.com \
    --to=safinaskar@gmail.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=superm1@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).