1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_COREDUMP_H
3 #define _LINUX_COREDUMP_H
5 #include <linux/types.h>
8 #include <asm/siginfo.h>
10 #ifdef CONFIG_COREDUMP
11 struct core_vma_metadata
{
12 unsigned long start
, end
;
14 unsigned long dump_size
;
19 struct coredump_params
{
20 const kernel_siginfo_t
*siginfo
;
23 unsigned long mm_flags
;
30 struct core_vma_metadata
*vma_meta
;
33 extern unsigned int core_file_note_size_limit
;
36 * These are the only things you should do on a core-file: use only these
37 * functions to write out all the necessary info.
39 extern void dump_skip_to(struct coredump_params
*cprm
, unsigned long to
);
40 extern void dump_skip(struct coredump_params
*cprm
, size_t nr
);
41 extern int dump_emit(struct coredump_params
*cprm
, const void *addr
, int nr
);
42 extern int dump_align(struct coredump_params
*cprm
, int align
);
43 int dump_user_range(struct coredump_params
*cprm
, unsigned long start
,
45 extern void do_coredump(const kernel_siginfo_t
*siginfo
);
48 * Logging for the coredump code, ratelimited.
49 * The TGID and comm fields are added to the message.
52 #define __COREDUMP_PRINTK(Level, Format, ...) \
54 char comm[TASK_COMM_LEN]; \
56 get_task_comm(comm, current); \
57 printk_ratelimited(Level "coredump: %d(%*pE): " Format "\n", \
58 task_tgid_vnr(current), (int)strlen(comm), comm, ##__VA_ARGS__); \
61 #define coredump_report(fmt, ...) __COREDUMP_PRINTK(KERN_INFO, fmt, ##__VA_ARGS__)
62 #define coredump_report_failure(fmt, ...) __COREDUMP_PRINTK(KERN_WARNING, fmt, ##__VA_ARGS__)
65 static inline void do_coredump(const kernel_siginfo_t
*siginfo
) {}
67 #define coredump_report(...)
68 #define coredump_report_failure(...)
72 #if defined(CONFIG_COREDUMP) && defined(CONFIG_SYSCTL)
73 extern void validate_coredump_safety(void);
75 static inline void validate_coredump_safety(void) {}
78 #endif /* _LINUX_COREDUMP_H */