Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] makedumpfile: make reserve_diskspace do nothing for flattened format
@ 2024-06-19 12:04 Jiri Bohac
  2024-07-19  8:00 ` HAGIO KAZUHITO(萩尾 一仁)
  0 siblings, 1 reply; 3+ messages in thread
From: Jiri Bohac @ 2024-06-19 12:04 UTC (permalink / raw)
  To: kexec

makedumpfile: make reserve_diskspace do nothing for flattened format

reserve_diskspace() is called by write_elf_header() to make sure there is
always space to write the program header, even if writing other data fails
because of ENOSPC.

This is harmful when writing the flattened format to STDOUT for two reasons:

First, it actually wastes disk space, because first the block of zeroes is sent
to STDOUT by reserve_diskspace() and then the actual program header is sent,
meant to overwrite the zeroes when the flattened format is rearranged.

Second, the algorithm used to read flattened format directly by the crash
program does not cope with the flattened file containing two chunks meant for
the same offset. It uses a binary search on a sorted array of flat_data headers
to find the data in the flat file. It may return the zeroed chunk written by
reserve_diskspace() near the beginning of the file instead of the actual ELF
header located near the end of the flattened file.

Fixes: e39216fce9f73759509ec158e39c289e6c211125 ("Make the incomplete dumpfile generated by ENOSPC error analyzable.")
Signed-off-by: Jiri Bohac <jbohac@suse.cz>

---
 makedumpfile.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/makedumpfile.c b/makedumpfile.c
index cadc596..9624c3f 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -5206,6 +5206,9 @@ reserve_diskspace(int fd, off_t start_offset, off_t end_offset, char *file_name)
 
 	int ret = FALSE;
 
+	if (info->flag_flatten)
+		return TRUE;
+
 	assert(start_offset < end_offset);
 	buf_size = end_offset - start_offset;
 
-- 
2.43.0

-- 
Jiri Bohac <jbohac@suse.cz>
SUSE Labs, Prague, Czechia


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-06  9:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-19 12:04 [PATCH] makedumpfile: make reserve_diskspace do nothing for flattened format Jiri Bohac
2024-07-19  8:00 ` HAGIO KAZUHITO(萩尾 一仁)
2024-08-06  9:02   ` [PATCH makedumpfile] " YAMAZAKI MASAMITSU(山崎 真光)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox