makedumpfile: Fix off-by-one issue in exclude_nodata_pages()
Subsystems (2)
PATCH 1/1 makedumpfile: Fix off-by-one issue in exclude_nodata_pages()
When building a dump bitmap (2nd bitmap) for the ELF dump, the last pfn of the cycle is always ignored in exclude_nodata_pages() function due to off-by-one error on cycle boundary check. Thus, the respective bit of the bitmap is never cleared.
That can lead to the error when such a pfn should not be dumpable (e.g. the last pfn of the ELF-load of zero filesize). Based on the bit in the bitmap the page is treated as dumpable in write_elf_pages_cyclic() function and the follow on error is triggered in write_elf_load_segment() function due to the failing sanity check of paddr_to_offset2():
$ makedumpfile -E dump.elf dump.elf.E Checking for memory holes : [100.0 %] | write_elf_load_segment: Can't convert physaddr(7ffff000) to an offset. makedumpfile Failed.
--- makedumpfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
makedumpfile.c +1 -1
@@ -4740,7 +4740,7 @@ exclude_nodata_pages(struct cycle *cycle)if (pfn < cycle->start_pfn) pfn = cycle->start_pfn;if (pfn_end >= cycle->end_pfn) - pfn_end = cycle->end_pfn -1 ; + pfn_end = cycle->end_pfn;while (pfn < pfn_end) {clear_bit_on_2nd_bitmap (pfn, cycle); ++pfn;
Signature · 7 lines
2.17.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Hi Mikhail,
Quoted 10 lines
-----Original Message-----
When building a dump bitmap (2nd bitmap) for the ELF dump, the last pfn of the cycle is always ignored inexclude_nodata_pages()function due to off-by-one error on cycle boundary check. Thus, the respective bit of the bitmap is never cleared.
That can lead to the error when such a pfn should not be dumpable (e.g. the last pfn of the ELF-load of zero filesize). Based on the bit in the bitmap the page is treated as dumpable inwrite_elf_pages_cyclic()function and the follow on error is triggered inwrite_elf_load_segment()function due to the failing sanity check ofpaddr_to_offset2():
Good catch. I could reproduce this issue with a vmcore on hand and confirm that the patch fixed it. Looks good to me, applied.
Thanks,
Kazu
Quoted 28 lines
$ makedumpfile -E dump.elf dump.elf.E Checking for memory holes : [100.0 %] | write_elf_load_segment: Can't convert physaddr(7ffff000) to an offset. makedumpfile Failed.Signed-off-by Mikhail Zaslonko <[email protected]>--- makedumpfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)makedumpfile.c +1
-2@@ -4740,7 +4740,7 @@ exclude_nodata_pages(struct cycle *cycle)if (pfn < cycle->start_pfn) pfn = cycle->start_pfn;if (pfn_end >= cycle->end_pfn) - pfn_end = cycle->end_pfn -1 ; + pfn_end = cycle->end_pfn;while (pfn < pfn_end) {clear_bit_on_2nd_bitmap (pfn, cycle); ++pfn; --2.17.1
Quoted 4 lines
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec