Skip to content

Commit 08fc35f

Browse files
brenns10akpm00
authored andcommitted
vmcoreinfo: warn if we exceed vmcoreinfo data size
Though vmcoreinfo is intended to be small, at just one page, useful information is still added to it, so we risk running out of space. Currently there is no runtime check to see whether the vmcoreinfo buffer has been exhausted. Add a warning for this case. Currently, my static checking tool[1] indicates that a good upper bound for vmcoreinfo size is currently 3415 bytes, but the best time to add warnings is before the risk becomes too high. [1] https://github.com/brenns10/kernel_stuff/blob/master/vmcoreinfosize/vmcoreinfosize.py Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Stephen Brennan <[email protected]> Acked-by: Baoquan He <[email protected]> Cc: Dave Young <[email protected]> Cc: Vivek Goyal <[email protected]> Cc: Kees Cook <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 3965292 commit 08fc35f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kernel/crash_core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,9 @@ void vmcoreinfo_append_str(const char *fmt, ...)
383383
memcpy(&vmcoreinfo_data[vmcoreinfo_size], buf, r);
384384

385385
vmcoreinfo_size += r;
386+
387+
WARN_ONCE(vmcoreinfo_size == VMCOREINFO_BYTES,
388+
"vmcoreinfo data exceeds allocated size, truncating");
386389
}
387390

388391
/*

0 commit comments

Comments
 (0)