connector: add parent pid and tgid to coredump and exit events
Subsystems (2)
PATCH 1/1 connector: add parent pid and tgid to coredump and exit events
The intention is to get notified of process failures as soon as possible, before a possible core dumping (which could be very long) (e.g. in some process-manager). Coredump and exit process events are perfect for such use cases (see 2b5faa4c553f "connector: Added coredumping event to the process connector").
The problem is that for now the process-manager cannot know the parent of a dying process using connectors. This could be useful if the process-manager should monitor for failures only children of certain parents, so we could filter the coredump and exit events by parent process and/or thread ID.
Add parent pid and tgid to coredump and exit process connectors event data.
--- drivers/connector/cn_proc.c | 4 ++++ include/uapi/linux/cn_proc.h | 4 ++++ 2 files changed, 8 insertions(+)
drivers/connector/cn_proc.c +4 -0
@@ -262,6 +262,8 @@ void proc_coredump_connector(struct task_struct *task) ev->what =PROC_EVENT_COREDUMP ; ev->event_data.coredump.process_pid = task->pid; ev->event_data.coredump.process_tgid = task->tgid; + ev->event_data.coredump.parent_pid = task->real_parent->pid; + ev->event_data.coredump.parent_tgid = task->real_parent->tgid;memcpy (&msg->id, &cn_proc_event_id,sizeof (msg->id)); msg->ack =0 ;/* not used */
@@ -288,6 +290,8 @@ void proc_exit_connector(struct task_struct *task) ev->event_data.exit.process_tgid = task->tgid; ev->event_data.exit.exit_code = task->exit_code; ev->event_data.exit.exit_signal = task->exit_signal; + ev->event_data.exit.parent_pid = task->real_parent->pid; + ev->event_data.exit.parent_tgid = task->real_parent->tgid;memcpy (&msg->id, &cn_proc_event_id,sizeof (msg->id)); msg->ack =0 ;/* not used */
include/uapi/linux/cn_proc.h +4 -0
@@ -116,12 +116,16 @@ struct proc_event {struct coredump_proc_event {__kernel_pid_t process_pid;__kernel_pid_t process_tgid; +__kernel_pid_t parent_pid; +__kernel_pid_t parent_tgid; } coredump;struct exit_proc_event {__kernel_pid_t process_pid;__kernel_pid_t process_tgid;__u32 exit_code, exit_signal; +__kernel_pid_t parent_pid; +__kernel_pid_t parent_tgid; } exit; } event_data;
Signature · 1 line
2.11.0
David Miller
maintainerFrom: Stefan Strogin <[email protected]>
Date: Thu, 29 Mar 2018 17:12:47 +0300
Quoted 11 lines
include/uapi/linux/cn_proc.h +2
-0@@ -116,12 +116,16 @@ struct proc_event {struct coredump_proc_event {__kernel_pid_t process_pid;__kernel_pid_t process_tgid; +__kernel_pid_t parent_pid; +__kernel_pid_t parent_tgid; } coredump;
include/uapi/linux/cn_proc.h struct proc_event { · line 131
Quoted 10 lines
include/uapi/linux/cn_proc.h +2
-0struct exit_proc_event {__kernel_pid_t process_pid;__kernel_pid_t process_tgid;__u32 exit_code, exit_signal; +__kernel_pid_t parent_pid; +__kernel_pid_t parent_tgid; } exit; } event_data;
I don't think you can add these members without breaking UAPI.
Hi David,
I don't see how it breaks UAPI. The point is that structures coredump_proc_event and exit_proc_event are members of *union* event_data, thus position of the existing data in the structure is unchanged. Furthermore, this change won't increase size of struct proc_event, because comm_proc_event (also a member of event_data) is of bigger size than the changed structures.
If I'm wrong, could you please explain what exactly will the change break in UAPI?
Quoted 27 lines · David Miller
From: Stefan Strogin <[email protected]>
Date: Thu, 29 Mar 2018 17:12:47 +0300Quoted 11 lines
include/uapi/linux/cn_proc.h +2
-0@@ -116,12 +116,16 @@ struct proc_event {struct coredump_proc_event {__kernel_pid_t process_pid;__kernel_pid_t process_tgid; +__kernel_pid_t parent_pid; +__kernel_pid_t parent_tgid; } coredump;include/uapi/linux/cn_proc.h struct proc_event { · line 131
Quoted 10 lines
include/uapi/linux/cn_proc.h +2
-0struct exit_proc_event {__kernel_pid_t process_pid;__kernel_pid_t process_tgid;__u32 exit_code, exit_signal; +__kernel_pid_t parent_pid; +__kernel_pid_t parent_tgid; } exit; } event_data;I don't think you can add these members without breaking UAPI.
A message that is not in the archive (sent off-list or not yet received): DB6P190MB0389513E240BD8ECEE575DB4DDBB0@DB6P190MB0389.EURP190.PROD.OUTLOOK.COM
Hi David, Evgeniy,
Sorry to bother you, but could you please comment about the UAPI change and the patch?
Thanks, Jesper.
--
Stefan
Quoted 53 lines · Jesper Derehag
Unless David comes back with something I have (also) missed regarding uapi breakage, this looks good to me.
/Jesper
________________________________________
Från: Stefan Strogin <[email protected]>
Skickat: den 2 april 2018 17:18
Till: David Miller
Kopia: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected] Ämne: Re: [PATCH] connector: add parent pid and tgid to coredump and exit eventsHi David,
I don't see how it breaks UAPI. The point is that structures
coredump_proc_eventandexit_proc_eventare members of *union*event_data, thus position of the existing data in the structure is unchanged. Furthermore, this change won't increase size of structproc_event, becausecomm_proc_event(also a member ofevent_data) is of bigger size than the changed structures.If I'm wrong, could you please explain what exactly will the change break in UAPI?
Quoted 27 lines · David Miller
From: Stefan Strogin <[email protected]>
Date: Thu, 29 Mar 2018 17:12:47 +0300Quoted 11 lines
include/uapi/linux/cn_proc.h +2
-0@@ -116,12 +116,16 @@ struct proc_event {struct coredump_proc_event {__kernel_pid_t process_pid;__kernel_pid_t process_tgid; +__kernel_pid_t parent_pid; +__kernel_pid_t parent_tgid; } coredump;include/uapi/linux/cn_proc.h struct proc_event { · line 131
Quoted 10 lines
include/uapi/linux/cn_proc.h +2
-0struct exit_proc_event {__kernel_pid_t process_pid;__kernel_pid_t process_tgid;__u32 exit_code, exit_signal; +__kernel_pid_t parent_pid; +__kernel_pid_t parent_tgid; } exit; } event_data;I don't think you can add these members without breaking UAPI.
Evgeniy Polyakov
Acked-byStefan, hi
Sorry for delay.
26.04.2018, 15:04, "Stefan Strogin" <[email protected]>:
Quoted 3 lines
Hi David, Evgeniy,
Sorry to bother you, but could you please comment about the UAPI change and the patch?
With 4-bytes pid_t everything looks fine, and I do not know arch where pid is larger currently, so it looks safe.
David, please pull it into your tree, or should it go via different path?
Quoted 37 lines
Quoted 37 lines
I don't see how it breaks UAPI. The point is that structures
coredump_proc_eventandexit_proc_eventare members of *union*event_data, thus position of the existing data in the structure is unchanged. Furthermore, this change won't increase size of structproc_event, becausecomm_proc_event(also a member ofevent_data) is of bigger size than the changed structures.If I'm wrong, could you please explain what exactly will the change break in UAPI?
Quoted 26 lines · David Miller
From: Stefan Strogin <[email protected]>
Date: Thu, 29 Mar 2018 17:12:47 +0300Quoted 20 lines
diff --git
a/include/uapi/linux/cn_proc.hb/include/uapi/linux/cn_proc.hindex68ff25414700..db210625cee8100644
---a/include/uapi/linux/cn_proc.h
+++b/include/uapi/linux/cn_proc.h
@@ -116,12 +116,16 @@ structproc_event{
structcoredump_proc_event{
__kernel_pid_tprocess_pid;__kernel_pid_tprocess_tgid;
+__kernel_pid_tparent_pid;
+__kernel_pid_tparent_tgid;
} coredump;struct
exit_proc_event{__kernel_pid_tprocess_pid;__kernel_pid_tprocess_tgid;__u32exit_code,exit_signal;
+__kernel_pid_tparent_pid;
+__kernel_pid_tparent_tgid;
} exit;Quoted 1 line
}
event_data;I don't think you can add these members without breaking UAPI.
David Miller
maintainerFrom: Evgeniy Polyakov <[email protected]>
Date: Mon, 30 Apr 2018 18:01:30 +0300
Quoted 7 lines
Stefan, hi
Sorry for delay.
26.04.2018, 15:04, "Stefan Strogin" <[email protected]>:
Quoted 2 lines
Hi David, Evgeniy,
Quoted 7 lines
Quoted 1 line
Sorry to bother you, but could you please comment about the UAPI change and the patch?
With 4-bytes
pid_teverything looks fine, and I do not know arch where pid is larger currently, so it looks safe.David, please pull it into your tree, or should it go via different path?
Acked-by Evgeniy Polyakov <[email protected]>
After this much time it needs to be resubmitted.