migration: validate page_size in mapped-ram header before use
mapped_ram_read_header() reads page_size from the migration stream and stores it in MappedRamHeader, but does not validate that the value is non-zero before it is later used in parse_ramblock_mapped_ram(): num_pages = length / header.page_size; If a corrupted or malformed migration stream provides invalid, guest resumes either with corrupted memory or crashes unexpectedly (eg. page_size = 0) Add validation in mapped_ram_read_header() to reject invalid page_size values early and return an error instead of continuing with an invalid header. Steps to reproduce: Create a migration snapshot with mapped-ram enabled: (qemu) migrate_set_capability mapped-ram on (qemu) migrate file:/tmp/qemu-snapshots/snapshot.bin Modify the snapshot so that MappedRamHeader.page_size becomes diff with target psize. (0/512/8192/1GB). Restore the snapshot: (qemu) migrate_set_capability mapped-ram on (qemu) migrate_incoming file:/tmp/qemu-snapshots/snapshot.bin As-is: * [0]: Floating point exception (core dumped) * [512/8192]: Silent corruption * [1GB]: "post load hook failed for: kvm-tpr-opt" (EPERM) To-be: * All: qemu-system-x86_64: Migration mapped-ram header has invalid page_size [val] (expected 4096) Signed-off-by: Trieu Huynh <vikingtc4@gmail.com> Reviewed-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Peter Xu <peterx@redhat.com> Link: https://lore.kernel.org/qemu-devel/20260405094447.11347-1-viking4@gmail.com Signed-off-by: Fabiano Rosas <farosas@suse.de>