xref: /linux-6.15/include/linux/coredump.h (revision 5cc81d5c)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_COREDUMP_H
3 #define _LINUX_COREDUMP_H
4 
5 #include <linux/types.h>
6 #include <linux/mm.h>
7 #include <linux/fs.h>
8 #include <asm/siginfo.h>
9 
10 #ifdef CONFIG_COREDUMP
11 struct core_vma_metadata {
12 	unsigned long start, end;
13 	unsigned long flags;
14 	unsigned long dump_size;
15 	unsigned long pgoff;
16 	struct file   *file;
17 };
18 
19 struct coredump_params {
20 	const kernel_siginfo_t *siginfo;
21 	struct pt_regs *regs;
22 	struct file *file;
23 	unsigned long limit;
24 	unsigned long mm_flags;
25 	int cpu;
26 	loff_t written;
27 	loff_t pos;
28 	loff_t to_skip;
29 	int vma_count;
30 	size_t vma_data_size;
31 	struct core_vma_metadata *vma_meta;
32 };
33 
34 /*
35  * These are the only things you should do on a core-file: use only these
36  * functions to write out all the necessary info.
37  */
38 extern void dump_skip_to(struct coredump_params *cprm, unsigned long to);
39 extern void dump_skip(struct coredump_params *cprm, size_t nr);
40 extern int dump_emit(struct coredump_params *cprm, const void *addr, int nr);
41 extern int dump_align(struct coredump_params *cprm, int align);
42 int dump_user_range(struct coredump_params *cprm, unsigned long start,
43 		    unsigned long len);
44 extern void do_coredump(const kernel_siginfo_t *siginfo);
45 #else
46 static inline void do_coredump(const kernel_siginfo_t *siginfo) {}
47 #endif
48 
49 #if defined(CONFIG_COREDUMP) && defined(CONFIG_SYSCTL)
50 extern void validate_coredump_safety(void);
51 #else
52 static inline void validate_coredump_safety(void) {}
53 #endif
54 
55 #endif /* _LINUX_COREDUMP_H */
56