Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Daisuke HATAYAMA | 088e7af | 2010-03-05 13:44:06 -0800 | [diff] [blame] | 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> |
Richard Weinberger | 1d46e23 | 2012-10-19 13:56:47 -0700 | [diff] [blame] | 8 | #include <asm/siginfo.h> |
Daisuke HATAYAMA | 088e7af | 2010-03-05 13:44:06 -0800 | [diff] [blame] | 9 | |
Al Viro | a64b890 | 2021-01-03 20:51:48 -0500 | [diff] [blame] | 10 | #ifdef CONFIG_COREDUMP |
Jann Horn | a07279c | 2020-10-15 20:12:54 -0700 | [diff] [blame] | 11 | struct core_vma_metadata { |
| 12 | unsigned long start, end; |
| 13 | unsigned long flags; |
| 14 | unsigned long dump_size; |
| 15 | }; |
| 16 | |
Eric W. Biederman | a99a3e2 | 2022-01-31 11:50:46 -0600 | [diff] [blame] | 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; |
Eric W. Biederman | 95c5436 | 2022-03-08 12:55:29 -0600 | [diff] [blame^] | 26 | int vma_count; |
| 27 | size_t vma_data_size; |
| 28 | struct core_vma_metadata *vma_meta; |
Eric W. Biederman | a99a3e2 | 2022-01-31 11:50:46 -0600 | [diff] [blame] | 29 | }; |
| 30 | |
Daisuke HATAYAMA | 088e7af | 2010-03-05 13:44:06 -0800 | [diff] [blame] | 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 | */ |
Al Viro | d0f1088 | 2020-03-08 09:16:37 -0400 | [diff] [blame] | 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); |
Al Viro | ecc8c77 | 2013-10-05 15:32:35 -0400 | [diff] [blame] | 37 | extern int dump_emit(struct coredump_params *cprm, const void *addr, int nr); |
Al Viro | 22a8cb8 | 2013-10-08 11:05:01 -0400 | [diff] [blame] | 38 | extern int dump_align(struct coredump_params *cprm, int align); |
Jann Horn | afc63a97b | 2020-10-15 20:12:46 -0700 | [diff] [blame] | 39 | int dump_user_range(struct coredump_params *cprm, unsigned long start, |
| 40 | unsigned long len); |
Eric W. Biederman | ae7795b | 2018-09-25 11:27:20 +0200 | [diff] [blame] | 41 | extern void do_coredump(const kernel_siginfo_t *siginfo); |
Alex Kelly | 179899fd | 2012-10-04 17:15:24 -0700 | [diff] [blame] | 42 | #else |
Eric W. Biederman | ae7795b | 2018-09-25 11:27:20 +0200 | [diff] [blame] | 43 | static inline void do_coredump(const kernel_siginfo_t *siginfo) {} |
Alex Kelly | 179899fd | 2012-10-04 17:15:24 -0700 | [diff] [blame] | 44 | #endif |
Daisuke HATAYAMA | 088e7af | 2010-03-05 13:44:06 -0800 | [diff] [blame] | 45 | |
Xiaoming Ni | f0bc21b | 2022-01-21 22:13:38 -0800 | [diff] [blame] | 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 | |
Daisuke HATAYAMA | 088e7af | 2010-03-05 13:44:06 -0800 | [diff] [blame] | 52 | #endif /* _LINUX_COREDUMP_H */ |