mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-16 18:26:42 +00:00
4bbf9c3b53
Introduce the capability to dynamically configure the maximum file note size for ELF core dumps via sysctl. Why is this being done? We have observed that during a crash when there are more than 65k mmaps in memory, the existing fixed limit on the size of the ELF notes section becomes a bottleneck. The notes section quickly reaches its capacity, leading to incomplete memory segment information in the resulting coredump. This truncation compromises the utility of the coredumps, as crucial information about the memory state at the time of the crash might be omitted. This enhancement removes the previous static limit of 4MB, allowing system administrators to adjust the size based on system-specific requirements or constraints. Eg: $ sysctl -a | grep core_file_note_size_limit kernel.core_file_note_size_limit = 4194304 $ sysctl -n kernel.core_file_note_size_limit 4194304 $echo 519304 > /proc/sys/kernel/core_file_note_size_limit $sysctl -n kernel.core_file_note_size_limit 519304 Attempting to write beyond the ceiling value of 16MB $echo 17194304 > /proc/sys/kernel/core_file_note_size_limit bash: echo: write error: Invalid argument Signed-off-by: Vijay Nag <nagvijay@microsoft.com> Signed-off-by: Allen Pais <apais@linux.microsoft.com> Link: https://lore.kernel.org/r/20240506193700.7884-1-apais@linux.microsoft.com Signed-off-by: Kees Cook <keescook@chromium.org>
57 lines
1.5 KiB
C
57 lines
1.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _LINUX_COREDUMP_H
|
|
#define _LINUX_COREDUMP_H
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/fs.h>
|
|
#include <asm/siginfo.h>
|
|
|
|
#ifdef CONFIG_COREDUMP
|
|
struct core_vma_metadata {
|
|
unsigned long start, end;
|
|
unsigned long flags;
|
|
unsigned long dump_size;
|
|
unsigned long pgoff;
|
|
struct file *file;
|
|
};
|
|
|
|
struct coredump_params {
|
|
const kernel_siginfo_t *siginfo;
|
|
struct file *file;
|
|
unsigned long limit;
|
|
unsigned long mm_flags;
|
|
int cpu;
|
|
loff_t written;
|
|
loff_t pos;
|
|
loff_t to_skip;
|
|
int vma_count;
|
|
size_t vma_data_size;
|
|
struct core_vma_metadata *vma_meta;
|
|
};
|
|
|
|
extern unsigned int core_file_note_size_limit;
|
|
|
|
/*
|
|
* These are the only things you should do on a core-file: use only these
|
|
* functions to write out all the necessary info.
|
|
*/
|
|
extern void dump_skip_to(struct coredump_params *cprm, unsigned long to);
|
|
extern void dump_skip(struct coredump_params *cprm, size_t nr);
|
|
extern int dump_emit(struct coredump_params *cprm, const void *addr, int nr);
|
|
extern int dump_align(struct coredump_params *cprm, int align);
|
|
int dump_user_range(struct coredump_params *cprm, unsigned long start,
|
|
unsigned long len);
|
|
extern void do_coredump(const kernel_siginfo_t *siginfo);
|
|
#else
|
|
static inline void do_coredump(const kernel_siginfo_t *siginfo) {}
|
|
#endif
|
|
|
|
#if defined(CONFIG_COREDUMP) && defined(CONFIG_SYSCTL)
|
|
extern void validate_coredump_safety(void);
|
|
#else
|
|
static inline void validate_coredump_safety(void) {}
|
|
#endif
|
|
|
|
#endif /* _LINUX_COREDUMP_H */
|