blob: 08a1d3e7e46d0a5c50fbdc73e7c982cca5da1daf [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Daisuke HATAYAMA088e7af2010-03-05 13:44:06 -08002#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 Weinberger1d46e232012-10-19 13:56:47 -07008#include <asm/siginfo.h>
Daisuke HATAYAMA088e7af2010-03-05 13:44:06 -08009
Al Viroa64b8902021-01-03 20:51:48 -050010#ifdef CONFIG_COREDUMP
Jann Horna07279c2020-10-15 20:12:54 -070011struct core_vma_metadata {
12 unsigned long start, end;
13 unsigned long flags;
14 unsigned long dump_size;
Eric W. Biederman390031c2022-03-08 13:04:19 -060015 unsigned long pgoff;
16 struct file *file;
Jann Horna07279c2020-10-15 20:12:54 -070017};
18
Eric W. Biedermana99a3e22022-01-31 11:50:46 -060019struct 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 loff_t written;
26 loff_t pos;
27 loff_t to_skip;
Eric W. Biederman95c54362022-03-08 12:55:29 -060028 int vma_count;
29 size_t vma_data_size;
30 struct core_vma_metadata *vma_meta;
Eric W. Biedermana99a3e22022-01-31 11:50:46 -060031};
32
Daisuke HATAYAMA088e7af2010-03-05 13:44:06 -080033/*
34 * These are the only things you should do on a core-file: use only these
35 * functions to write out all the necessary info.
36 */
Al Virod0f10882020-03-08 09:16:37 -040037extern void dump_skip_to(struct coredump_params *cprm, unsigned long to);
38extern void dump_skip(struct coredump_params *cprm, size_t nr);
Al Viroecc8c772013-10-05 15:32:35 -040039extern int dump_emit(struct coredump_params *cprm, const void *addr, int nr);
Al Viro22a8cb82013-10-08 11:05:01 -040040extern int dump_align(struct coredump_params *cprm, int align);
Jann Hornafc63a97b2020-10-15 20:12:46 -070041int dump_user_range(struct coredump_params *cprm, unsigned long start,
42 unsigned long len);
Eric W. Biedermanae7795b2018-09-25 11:27:20 +020043extern void do_coredump(const kernel_siginfo_t *siginfo);
Alex Kelly179899fd2012-10-04 17:15:24 -070044#else
Eric W. Biedermanae7795b2018-09-25 11:27:20 +020045static inline void do_coredump(const kernel_siginfo_t *siginfo) {}
Alex Kelly179899fd2012-10-04 17:15:24 -070046#endif
Daisuke HATAYAMA088e7af2010-03-05 13:44:06 -080047
Xiaoming Nif0bc21b2022-01-21 22:13:38 -080048#if defined(CONFIG_COREDUMP) && defined(CONFIG_SYSCTL)
49extern void validate_coredump_safety(void);
50#else
51static inline void validate_coredump_safety(void) {}
52#endif
53
Daisuke HATAYAMA088e7af2010-03-05 13:44:06 -080054#endif /* _LINUX_COREDUMP_H */