coredump: Snapshot the vmas in do_coredump
[linux-block.git] / include / linux / coredump.h
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 };
16
17 struct coredump_params {
18         const kernel_siginfo_t *siginfo;
19         struct pt_regs *regs;
20         struct file *file;
21         unsigned long limit;
22         unsigned long mm_flags;
23         loff_t written;
24         loff_t pos;
25         loff_t to_skip;
26         int vma_count;
27         size_t vma_data_size;
28         struct core_vma_metadata *vma_meta;
29 };
30
31 /*
32  * These are the only things you should do on a core-file: use only these
33  * functions to write out all the necessary info.
34  */
35 extern void dump_skip_to(struct coredump_params *cprm, unsigned long to);
36 extern void dump_skip(struct coredump_params *cprm, size_t nr);
37 extern int dump_emit(struct coredump_params *cprm, const void *addr, int nr);
38 extern int dump_align(struct coredump_params *cprm, int align);
39 int dump_user_range(struct coredump_params *cprm, unsigned long start,
40                     unsigned long len);
41 extern void do_coredump(const kernel_siginfo_t *siginfo);
42 #else
43 static inline void do_coredump(const kernel_siginfo_t *siginfo) {}
44 #endif
45
46 #if defined(CONFIG_COREDUMP) && defined(CONFIG_SYSCTL)
47 extern void validate_coredump_safety(void);
48 #else
49 static inline void validate_coredump_safety(void) {}
50 #endif
51
52 #endif /* _LINUX_COREDUMP_H */