1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2
3#ifndef _UAPI_LINUX_COREDUMP_H
4#define _UAPI_LINUX_COREDUMP_H
5
6#include <linux/types.h>
7
8/**
9 * coredump_{req,ack} flags
10 * @COREDUMP_KERNEL: kernel writes coredump
11 * @COREDUMP_USERSPACE: userspace writes coredump
12 * @COREDUMP_REJECT: don't generate coredump
13 * @COREDUMP_WAIT: wait for coredump server
14 */
15enum {
16 COREDUMP_KERNEL = (1ULL << 0),
17 COREDUMP_USERSPACE = (1ULL << 1),
18 COREDUMP_REJECT = (1ULL << 2),
19 COREDUMP_WAIT = (1ULL << 3),
20};
21
22/**
23 * struct coredump_req - message kernel sends to userspace
24 * @size: size of struct coredump_req
25 * @size_ack: known size of struct coredump_ack on this kernel
26 * @mask: supported features
27 *
28 * When a coredump happens the kernel will connect to the coredump
29 * socket and send a coredump request to the coredump server. The @size
30 * member is set to the size of struct coredump_req and provides a hint
31 * to userspace how much data can be read. Userspace may use MSG_PEEK to
32 * peek the size of struct coredump_req and then choose to consume it in
33 * one go. Userspace may also simply read a COREDUMP_ACK_SIZE_VER0
34 * request. If the size the kernel sends is larger userspace simply
35 * discards any remaining data.
36 *
37 * The coredump_req->mask member is set to the currently know features.
38 * Userspace may only set coredump_ack->mask to the bits raised by the
39 * kernel in coredump_req->mask.
40 *
41 * The coredump_req->size_ack member is set by the kernel to the size of
42 * struct coredump_ack the kernel knows. Userspace may only send up to
43 * coredump_req->size_ack bytes to the kernel and must set
44 * coredump_ack->size accordingly.
45 */
46struct coredump_req {
47 __u32 size;
48 __u32 size_ack;
49 __u64 mask;
50};
51
52enum {
53 COREDUMP_REQ_SIZE_VER0 = 16U, /* size of first published struct */
54};
55
56/**
57 * struct coredump_ack - message userspace sends to kernel
58 * @size: size of the struct
59 * @spare: unused
60 * @mask: features kernel is supposed to use
61 *
62 * The @size member must be set to the size of struct coredump_ack. It
63 * may never exceed what the kernel returned in coredump_req->size_ack
64 * but it may of course be smaller (>= COREDUMP_ACK_SIZE_VER0 and <=
65 * coredump_req->size_ack).
66 *
67 * The @mask member must be set to the features the coredump server
68 * wants the kernel to use. Only bits the kernel returned in
69 * coredump_req->mask may be set.
70 */
71struct coredump_ack {
72 __u32 size;
73 __u32 spare;
74 __u64 mask;
75};
76
77enum {
78 COREDUMP_ACK_SIZE_VER0 = 16U, /* size of first published struct */
79};
80
81/**
82 * enum coredump_mark - Markers for the coredump socket
83 *
84 * The kernel will place a single byte on the coredump socket. The
85 * markers notify userspace whether the coredump ack succeeded or
86 * failed.
87 *
88 * @COREDUMP_MARK_MINSIZE: the provided coredump_ack size was too small
89 * @COREDUMP_MARK_MAXSIZE: the provided coredump_ack size was too big
90 * @COREDUMP_MARK_UNSUPPORTED: the provided coredump_ack mask was invalid
91 * @COREDUMP_MARK_CONFLICTING: the provided coredump_ack mask has conflicting options
92 * @COREDUMP_MARK_REQACK: the coredump request and ack was successful
93 * @__COREDUMP_MARK_MAX: the maximum coredump mark value
94 */
95enum coredump_mark {
96 COREDUMP_MARK_REQACK = 0U,
97 COREDUMP_MARK_MINSIZE = 1U,
98 COREDUMP_MARK_MAXSIZE = 2U,
99 COREDUMP_MARK_UNSUPPORTED = 3U,
100 COREDUMP_MARK_CONFLICTING = 4U,
101 __COREDUMP_MARK_MAX = (1U << 31),
102};
103
104#endif /* _UAPI_LINUX_COREDUMP_H */
105