diff options
| -rw-r--r-- | drivers/connector/cn_proc.c | 25 | ||||
| -rw-r--r-- | include/linux/cn_proc.h | 10 | ||||
| -rw-r--r-- | kernel/exit.c | 4 |
3 files changed, 38 insertions, 1 deletions
diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c index 85e5dc0431fe..abf4a2529f80 100644 --- a/drivers/connector/cn_proc.c +++ b/drivers/connector/cn_proc.c | |||
| @@ -139,6 +139,31 @@ void proc_id_connector(struct task_struct *task, int which_id) | |||
| 139 | cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); | 139 | cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | void proc_sid_connector(struct task_struct *task) | ||
| 143 | { | ||
| 144 | struct cn_msg *msg; | ||
| 145 | struct proc_event *ev; | ||
| 146 | struct timespec ts; | ||
| 147 | __u8 buffer[CN_PROC_MSG_SIZE]; | ||
| 148 | |||
| 149 | if (atomic_read(&proc_event_num_listeners) < 1) | ||
| 150 | return; | ||
| 151 | |||
| 152 | msg = (struct cn_msg *)buffer; | ||
| 153 | ev = (struct proc_event *)msg->data; | ||
| 154 | get_seq(&msg->seq, &ev->cpu); | ||
| 155 | ktime_get_ts(&ts); /* get high res monotonic timestamp */ | ||
| 156 | put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); | ||
| 157 | ev->what = PROC_EVENT_SID; | ||
| 158 | ev->event_data.sid.process_pid = task->pid; | ||
| 159 | ev->event_data.sid.process_tgid = task->tgid; | ||
| 160 | |||
| 161 | memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); | ||
| 162 | msg->ack = 0; /* not used */ | ||
| 163 | msg->len = sizeof(*ev); | ||
| 164 | cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); | ||
| 165 | } | ||
| 166 | |||
| 142 | void proc_exit_connector(struct task_struct *task) | 167 | void proc_exit_connector(struct task_struct *task) |
| 143 | { | 168 | { |
| 144 | struct cn_msg *msg; | 169 | struct cn_msg *msg; |
diff --git a/include/linux/cn_proc.h b/include/linux/cn_proc.h index b8125b2eb665..47dac5ea8d3a 100644 --- a/include/linux/cn_proc.h +++ b/include/linux/cn_proc.h | |||
| @@ -52,6 +52,7 @@ struct proc_event { | |||
| 52 | PROC_EVENT_EXEC = 0x00000002, | 52 | PROC_EVENT_EXEC = 0x00000002, |
| 53 | PROC_EVENT_UID = 0x00000004, | 53 | PROC_EVENT_UID = 0x00000004, |
| 54 | PROC_EVENT_GID = 0x00000040, | 54 | PROC_EVENT_GID = 0x00000040, |
| 55 | PROC_EVENT_SID = 0x00000080, | ||
| 55 | /* "next" should be 0x00000400 */ | 56 | /* "next" should be 0x00000400 */ |
| 56 | /* "last" is the last process event: exit */ | 57 | /* "last" is the last process event: exit */ |
| 57 | PROC_EVENT_EXIT = 0x80000000 | 58 | PROC_EVENT_EXIT = 0x80000000 |
| @@ -89,6 +90,11 @@ struct proc_event { | |||
| 89 | } e; | 90 | } e; |
| 90 | } id; | 91 | } id; |
| 91 | 92 | ||
| 93 | struct sid_proc_event { | ||
| 94 | __kernel_pid_t process_pid; | ||
| 95 | __kernel_pid_t process_tgid; | ||
| 96 | } sid; | ||
| 97 | |||
| 92 | struct exit_proc_event { | 98 | struct exit_proc_event { |
| 93 | __kernel_pid_t process_pid; | 99 | __kernel_pid_t process_pid; |
| 94 | __kernel_pid_t process_tgid; | 100 | __kernel_pid_t process_tgid; |
| @@ -102,6 +108,7 @@ struct proc_event { | |||
| 102 | void proc_fork_connector(struct task_struct *task); | 108 | void proc_fork_connector(struct task_struct *task); |
| 103 | void proc_exec_connector(struct task_struct *task); | 109 | void proc_exec_connector(struct task_struct *task); |
| 104 | void proc_id_connector(struct task_struct *task, int which_id); | 110 | void proc_id_connector(struct task_struct *task, int which_id); |
| 111 | void proc_sid_connector(struct task_struct *task); | ||
| 105 | void proc_exit_connector(struct task_struct *task); | 112 | void proc_exit_connector(struct task_struct *task); |
| 106 | #else | 113 | #else |
| 107 | static inline void proc_fork_connector(struct task_struct *task) | 114 | static inline void proc_fork_connector(struct task_struct *task) |
| @@ -114,6 +121,9 @@ static inline void proc_id_connector(struct task_struct *task, | |||
| 114 | int which_id) | 121 | int which_id) |
| 115 | {} | 122 | {} |
| 116 | 123 | ||
| 124 | static inline void proc_sid_connector(struct task_struct *task) | ||
| 125 | {} | ||
| 126 | |||
| 117 | static inline void proc_exit_connector(struct task_struct *task) | 127 | static inline void proc_exit_connector(struct task_struct *task) |
| 118 | {} | 128 | {} |
| 119 | #endif /* CONFIG_PROC_EVENTS */ | 129 | #endif /* CONFIG_PROC_EVENTS */ |
diff --git a/kernel/exit.c b/kernel/exit.c index e47ee8a06135..61bb1761c7b8 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
| @@ -359,8 +359,10 @@ void __set_special_pids(struct pid *pid) | |||
| 359 | { | 359 | { |
| 360 | struct task_struct *curr = current->group_leader; | 360 | struct task_struct *curr = current->group_leader; |
| 361 | 361 | ||
| 362 | if (task_session(curr) != pid) | 362 | if (task_session(curr) != pid) { |
| 363 | change_pid(curr, PIDTYPE_SID, pid); | 363 | change_pid(curr, PIDTYPE_SID, pid); |
| 364 | proc_sid_connector(curr); | ||
| 365 | } | ||
| 364 | 366 | ||
| 365 | if (task_pgrp(curr) != pid) | 367 | if (task_pgrp(curr) != pid) |
| 366 | change_pid(curr, PIDTYPE_PGID, pid); | 368 | change_pid(curr, PIDTYPE_PGID, pid); |
