diff options
| author | Christian Brauner <brauner@kernel.org> | 2025-06-12 15:25:17 +0200 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2025-06-16 17:01:21 +0200 |
| commit | 67c3a0b0ad1a78d7ee9c3aadaed22561f7f85466 (patch) | |
| tree | 50cd329cab3569f66177d3fbd9438a1ff036c9a7 | |
| parent | a5715af549b2ee0139ff965d337cfd1a5f7ee615 (diff) | |
coredump: fix socket path validation
Make sure that we keep it extensible and well-formed.
Link: https://lore.kernel.org/20250612-work-coredump-massage-v1-3-315c0c34ba94@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
| -rw-r--r-- | fs/coredump.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/fs/coredump.c b/fs/coredump.c index 42ceb9db2a5a..70e37435eca9 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -1399,9 +1399,17 @@ static inline bool check_coredump_socket(void) if (current->nsproxy->mnt_ns != init_task.nsproxy->mnt_ns) return false; - /* Must be an absolute path or the socket request. */ - if (*(core_pattern + 1) != '/' && *(core_pattern + 1) != '@') + /* Must be an absolute path... */ + if (core_pattern[1] != '/') { + /* ... or the socket request protocol... */ + if (core_pattern[1] != '@') + return false; + /* ... and if so must be an absolute path. */ + if (core_pattern[2] != '/') + return false; + /* Anything else is unsupported. */ return false; + } return true; } |
