hibernate bug: "Image size after compression: -1210935 kbytes"
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.
Signature · 1 line
Askar Safin