[makedumpfile PATCH v2] Prevent data loss in last page of ELF core dumpfile

Daniel Kiper daniel.kiper at oracle.com
Wed Jul 5 15:49:14 PDT 2017


On Wed, Jul 05, 2017 at 12:13:22PM -0500, Eric DeVolder wrote:
> When generating an ELF core dump file, if a segment size
> is not an exact multiple of PAGE_SIZE, then the corresponding
> generated segment is erroneously truncated to a PAGE_SIZE multiple.
> Thus a small loss of data up to PAGE_SIZE-1 bytes can occur.

Some nit picks below...

[...]

> With the patch applied, the file size is again correct.
>
> Signed-off-by: Eric DeVolder <eric.devolder at oracle.com>
> ---
> v2: posted 05jul2017 to kexec-tools list
>  - feedback from Atsushi Kumagai pointed to real root of problem,
>    and patch changed accordingly
>
> v1: posted 03jul2017 to kexec-tools list
> ---
>  makedumpfile.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/makedumpfile.c b/makedumpfile.c
> index e69b6df..26296f1 100644
> --- a/makedumpfile.c
> +++ b/makedumpfile.c
> @@ -5410,7 +5410,8 @@ create_1st_bitmap_file(void)
>  		if (pfn_start > info->max_mapnr)
>  			continue;
>  		pfn_end = MIN(pfn_end, info->max_mapnr);
> -
> +        /* Account for last page if it has less than page_size data in it */
> +        if (phys_end & (info->page_size-1)) ++pfn_end;

Something is wrong with column alignment. Tabs instead of spaces?
And "++pfn_end;" should be in new line.

Daniel



More information about the kexec mailing list