[PATCH v8 6/9] coredump: show supported coredump modes

From: Christian Brauner
Date: Fri May 16 2025 - 07:28:48 EST


Allow userspace to discover what coredump modes are supported.

Acked-by: Luca Boccassi <luca.boccassi@xxxxxxxxx>
Reviewed-by: Jann Horn <jannh@xxxxxxxxxx>
Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@xxxxxxxxxxxxx>
Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>
---
fs/coredump.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/fs/coredump.c b/fs/coredump.c
index 48064b1d6305..7b9a659683fc 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -1227,6 +1227,12 @@ static int proc_dostring_coredump(const struct ctl_table *table, int write,

static const unsigned int core_file_note_size_min = CORE_FILE_NOTE_SIZE_DEFAULT;
static const unsigned int core_file_note_size_max = CORE_FILE_NOTE_SIZE_MAX;
+static char core_modes[] = {
+ "file\npipe"
+#ifdef CONFIG_UNIX
+ "\nsocket"
+#endif
+};

static const struct ctl_table coredump_sysctls[] = {
{
@@ -1270,6 +1276,13 @@ static const struct ctl_table coredump_sysctls[] = {
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
+ {
+ .procname = "core_modes",
+ .data = core_modes,
+ .maxlen = sizeof(core_modes) - 1,
+ .mode = 0444,
+ .proc_handler = proc_dostring,
+ },
};

static int __init init_fs_coredump_sysctls(void)

--
2.47.2