Skip to content

Commit 3d365b4

Browse files
committed
coredump: also stop forwarding non-dumpable processes
See the comment in the patch for details. Suggested-by: Qualys Security Advisory <[email protected]> (cherry-picked from commit 8fc7b2a) (cherry-picked from commit 101058955eb41023e0dba5766f6bfb190ebbb4f6) (cherry picked from commit 9c9e09ed85f89b9d42102211b9fa72492a16ef1b)
1 parent 254ab8d commit 3d365b4

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/coredump/coredump.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,10 +1415,21 @@ static int receive_ucred(int transport_fd, struct ucred *ret_ucred) {
14151415
return 0;
14161416
}
14171417

1418-
static int can_forward_coredump(pid_t pid) {
1418+
static int can_forward_coredump(Context *context, pid_t pid) {
14191419
_cleanup_free_ char *cgroup = NULL, *path = NULL, *unit = NULL;
14201420
int r;
14211421

1422+
assert(context);
1423+
1424+
/* We don't use %F/pidfd to pin down the crashed process yet. We need to avoid a situation where the
1425+
* attacker crashes a SUID process or a root daemon and quickly replaces it with a namespaced process
1426+
* and we forward the initial part of the coredump to the attacker, inside the namespace.
1427+
*
1428+
* TODO: relax this check when %F is implemented and used.
1429+
*/
1430+
if (context->dumpable != 1)
1431+
return false;
1432+
14221433
r = cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, pid, &cgroup);
14231434
if (r < 0)
14241435
return r;
@@ -1460,7 +1471,7 @@ static int forward_coredump_to_container(Context *context) {
14601471
if (r < 0)
14611472
return log_debug_errno(r, "Failed to get namespace leader: %m");
14621473

1463-
r = can_forward_coredump(pid);
1474+
r = can_forward_coredump(context, pid);
14641475
if (r < 0)
14651476
return log_debug_errno(r, "Failed to check if coredump can be forwarded: %m");
14661477
if (r == 0)

0 commit comments

Comments
 (0)