Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 164678
b: refs/heads/master
c: 02b51df
h: refs/heads/master
v: v3
  • Loading branch information
Scott James Remnant authored and Linus Torvalds committed Sep 23, 2009
1 parent 83e4b7d commit 80de10b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 88e9d34c727883d7d6f02cf1475b3ec98b8480c7
refs/heads/master: 02b51df1b07b4e9ca823c89284e704cadb323cd1
25 changes: 25 additions & 0 deletions trunk/drivers/connector/cn_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,31 @@ void proc_id_connector(struct task_struct *task, int which_id)
cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
}

void proc_sid_connector(struct task_struct *task)
{
struct cn_msg *msg;
struct proc_event *ev;
struct timespec ts;
__u8 buffer[CN_PROC_MSG_SIZE];

if (atomic_read(&proc_event_num_listeners) < 1)
return;

msg = (struct cn_msg *)buffer;
ev = (struct proc_event *)msg->data;
get_seq(&msg->seq, &ev->cpu);
ktime_get_ts(&ts); /* get high res monotonic timestamp */
put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
ev->what = PROC_EVENT_SID;
ev->event_data.sid.process_pid = task->pid;
ev->event_data.sid.process_tgid = task->tgid;

memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
msg->ack = 0; /* not used */
msg->len = sizeof(*ev);
cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
}

void proc_exit_connector(struct task_struct *task)
{
struct cn_msg *msg;
Expand Down
10 changes: 10 additions & 0 deletions trunk/include/linux/cn_proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct proc_event {
PROC_EVENT_EXEC = 0x00000002,
PROC_EVENT_UID = 0x00000004,
PROC_EVENT_GID = 0x00000040,
PROC_EVENT_SID = 0x00000080,
/* "next" should be 0x00000400 */
/* "last" is the last process event: exit */
PROC_EVENT_EXIT = 0x80000000
Expand Down Expand Up @@ -89,6 +90,11 @@ struct proc_event {
} e;
} id;

struct sid_proc_event {
__kernel_pid_t process_pid;
__kernel_pid_t process_tgid;
} sid;

struct exit_proc_event {
__kernel_pid_t process_pid;
__kernel_pid_t process_tgid;
Expand All @@ -102,6 +108,7 @@ struct proc_event {
void proc_fork_connector(struct task_struct *task);
void proc_exec_connector(struct task_struct *task);
void proc_id_connector(struct task_struct *task, int which_id);
void proc_sid_connector(struct task_struct *task);
void proc_exit_connector(struct task_struct *task);
#else
static inline void proc_fork_connector(struct task_struct *task)
Expand All @@ -114,6 +121,9 @@ static inline void proc_id_connector(struct task_struct *task,
int which_id)
{}

static inline void proc_sid_connector(struct task_struct *task)
{}

static inline void proc_exit_connector(struct task_struct *task)
{}
#endif /* CONFIG_PROC_EVENTS */
Expand Down
4 changes: 3 additions & 1 deletion trunk/kernel/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,10 @@ void __set_special_pids(struct pid *pid)
{
struct task_struct *curr = current->group_leader;

if (task_session(curr) != pid)
if (task_session(curr) != pid) {
change_pid(curr, PIDTYPE_SID, pid);
proc_sid_connector(curr);
}

if (task_pgrp(curr) != pid)
change_pid(curr, PIDTYPE_PGID, pid);
Expand Down

0 comments on commit 80de10b

Please sign in to comment.