Commit eee99b6a authored by Mathias Krause's avatar Mathias Krause Committed by Willy Tarreau

proc connector: fix info leaks

[ Upstream commit e727ca82 ]

Initialize event_data for all possible message types to prevent leaking
kernel stack contents to userland (up to 20 bytes). Also set the flags
member of the connector message to 0 to prevent leaking two more stack
bytes this way.

Cc: stable@vger.kernel.org  # v2.6.15+
Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
parent afd86e97
...@@ -59,6 +59,7 @@ void proc_fork_connector(struct task_struct *task) ...@@ -59,6 +59,7 @@ void proc_fork_connector(struct task_struct *task)
msg = (struct cn_msg*)buffer; msg = (struct cn_msg*)buffer;
ev = (struct proc_event*)msg->data; ev = (struct proc_event*)msg->data;
memset(&ev->event_data, 0, sizeof(ev->event_data));
get_seq(&msg->seq, &ev->cpu); get_seq(&msg->seq, &ev->cpu);
ktime_get_ts(&ts); /* get high res monotonic timestamp */ ktime_get_ts(&ts); /* get high res monotonic timestamp */
put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
...@@ -71,6 +72,7 @@ void proc_fork_connector(struct task_struct *task) ...@@ -71,6 +72,7 @@ void proc_fork_connector(struct task_struct *task)
memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
msg->ack = 0; /* not used */ msg->ack = 0; /* not used */
msg->len = sizeof(*ev); msg->len = sizeof(*ev);
msg->flags = 0; /* not used */
/* If cn_netlink_send() failed, the data is not sent */ /* If cn_netlink_send() failed, the data is not sent */
cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
} }
...@@ -87,6 +89,7 @@ void proc_exec_connector(struct task_struct *task) ...@@ -87,6 +89,7 @@ void proc_exec_connector(struct task_struct *task)
msg = (struct cn_msg*)buffer; msg = (struct cn_msg*)buffer;
ev = (struct proc_event*)msg->data; ev = (struct proc_event*)msg->data;
memset(&ev->event_data, 0, sizeof(ev->event_data));
get_seq(&msg->seq, &ev->cpu); get_seq(&msg->seq, &ev->cpu);
ktime_get_ts(&ts); /* get high res monotonic timestamp */ ktime_get_ts(&ts); /* get high res monotonic timestamp */
put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
...@@ -97,6 +100,7 @@ void proc_exec_connector(struct task_struct *task) ...@@ -97,6 +100,7 @@ void proc_exec_connector(struct task_struct *task)
memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
msg->ack = 0; /* not used */ msg->ack = 0; /* not used */
msg->len = sizeof(*ev); msg->len = sizeof(*ev);
msg->flags = 0; /* not used */
cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
} }
...@@ -113,6 +117,7 @@ void proc_id_connector(struct task_struct *task, int which_id) ...@@ -113,6 +117,7 @@ void proc_id_connector(struct task_struct *task, int which_id)
msg = (struct cn_msg*)buffer; msg = (struct cn_msg*)buffer;
ev = (struct proc_event*)msg->data; ev = (struct proc_event*)msg->data;
memset(&ev->event_data, 0, sizeof(ev->event_data));
ev->what = which_id; ev->what = which_id;
ev->event_data.id.process_pid = task->pid; ev->event_data.id.process_pid = task->pid;
ev->event_data.id.process_tgid = task->tgid; ev->event_data.id.process_tgid = task->tgid;
...@@ -136,6 +141,7 @@ void proc_id_connector(struct task_struct *task, int which_id) ...@@ -136,6 +141,7 @@ void proc_id_connector(struct task_struct *task, int which_id)
memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
msg->ack = 0; /* not used */ msg->ack = 0; /* not used */
msg->len = sizeof(*ev); msg->len = sizeof(*ev);
msg->flags = 0; /* not used */
cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
} }
...@@ -151,6 +157,7 @@ void proc_sid_connector(struct task_struct *task) ...@@ -151,6 +157,7 @@ void proc_sid_connector(struct task_struct *task)
msg = (struct cn_msg *)buffer; msg = (struct cn_msg *)buffer;
ev = (struct proc_event *)msg->data; ev = (struct proc_event *)msg->data;
memset(&ev->event_data, 0, sizeof(ev->event_data));
get_seq(&msg->seq, &ev->cpu); get_seq(&msg->seq, &ev->cpu);
ktime_get_ts(&ts); /* get high res monotonic timestamp */ ktime_get_ts(&ts); /* get high res monotonic timestamp */
put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
...@@ -161,6 +168,7 @@ void proc_sid_connector(struct task_struct *task) ...@@ -161,6 +168,7 @@ void proc_sid_connector(struct task_struct *task)
memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
msg->ack = 0; /* not used */ msg->ack = 0; /* not used */
msg->len = sizeof(*ev); msg->len = sizeof(*ev);
msg->flags = 0; /* not used */
cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
} }
...@@ -176,8 +184,10 @@ void proc_exit_connector(struct task_struct *task) ...@@ -176,8 +184,10 @@ void proc_exit_connector(struct task_struct *task)
msg = (struct cn_msg*)buffer; msg = (struct cn_msg*)buffer;
ev = (struct proc_event*)msg->data; ev = (struct proc_event*)msg->data;
memset(&ev->event_data, 0, sizeof(ev->event_data));
get_seq(&msg->seq, &ev->cpu); get_seq(&msg->seq, &ev->cpu);
ktime_get_ts(&ts); /* get high res monotonic timestamp */ ktime_get_ts(&ts); /* get high res monotonic timestamp */
memset(&ev->event_data, 0, sizeof(ev->event_data));
put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
ev->what = PROC_EVENT_EXIT; ev->what = PROC_EVENT_EXIT;
ev->event_data.exit.process_pid = task->pid; ev->event_data.exit.process_pid = task->pid;
...@@ -188,6 +198,7 @@ void proc_exit_connector(struct task_struct *task) ...@@ -188,6 +198,7 @@ void proc_exit_connector(struct task_struct *task)
memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
msg->ack = 0; /* not used */ msg->ack = 0; /* not used */
msg->len = sizeof(*ev); msg->len = sizeof(*ev);
msg->flags = 0; /* not used */
cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
} }
...@@ -211,6 +222,7 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack) ...@@ -211,6 +222,7 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack)
msg = (struct cn_msg*)buffer; msg = (struct cn_msg*)buffer;
ev = (struct proc_event*)msg->data; ev = (struct proc_event*)msg->data;
memset(&ev->event_data, 0, sizeof(ev->event_data));
msg->seq = rcvd_seq; msg->seq = rcvd_seq;
ktime_get_ts(&ts); /* get high res monotonic timestamp */ ktime_get_ts(&ts); /* get high res monotonic timestamp */
put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
...@@ -220,6 +232,7 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack) ...@@ -220,6 +232,7 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack)
memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
msg->ack = rcvd_ack + 1; msg->ack = rcvd_ack + 1;
msg->len = sizeof(*ev); msg->len = sizeof(*ev);
msg->flags = 0; /* not used */
cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment