Skip to contentSkip to conversation

+ make-good_sigevent-non-static.patch added to -mm tree

DISCUSSION Oleg Nesterov 2 participants 4 messages Jan 25, 2007 – Jan 26, 2007

lore
Share & tools
lore
#0 lore raw

Review

Quoted 11 lines · SИbastien DuguИ
(quoted diff) +10 -0
+struct task_struct *good_sigevent(sigevent_t *event)
+{
+	struct task_struct *task = current->group_leader;
+
+	if ((event->sigev_notify & SIGEV_THREAD_ID) == SIGEV_THREAD_ID) {
+		task = find_task_by_pid(event->sigev_notify_thread_id);
+
+		if (!task || task->tgid != current->tgid)
+			return NULL;
+	} else if (event->sigev_notify == SIGEV_SIGNAL) {

No, no, we can't use "else" here,

Review

Quoted 1 line
(quoted diff) +1 -0
+		if (event->sigev_signo <= 0 || event->sigev_signo > SIGRTMAX)

because we skip the check above in SIGEV_THREAD_ID case.

This way any user can crash the kernel with a minimal effort.

Oleg.

#1 lore raw
Quoted 15 lines · On Thu, 25 Jan 2007 18:43:24 +0300 Oleg Nesterov <[email protected]> wrote:

Review

Quoted 11 lines · SИbastien DuguИ
(quoted diff) +10 -0
+struct task_struct *good_sigevent(sigevent_t *event)
+{
+	struct task_struct *task = current->group_leader;
+
+	if ((event->sigev_notify & SIGEV_THREAD_ID) == SIGEV_THREAD_ID) {
+		task = find_task_by_pid(event->sigev_notify_thread_id);
+
+		if (!task || task->tgid != current->tgid)
+			return NULL;
+	} else if (event->sigev_notify == SIGEV_SIGNAL) {

No, no, we can't use "else" here,

Quoted 3 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+		if (event->sigev_signo <= 0 || event->sigev_signo > SIGRTMAX)

because we skip the check above in SIGEV_THREAD_ID case.

Right, will fix this.

Quoted 2 lines

This way any user can crash the kernel with a minimal effort.

Well I tried, no crash, just the signal failing to be delivered.

Thanks,

Sébastien.

#2 lore raw
Quoted 22 lines · S?bastien Dugu?
Quoted 15 lines · On Thu, 25 Jan 2007 18:43:24 +0300 Oleg Nesterov <[email protected]> wrote:

Review

Quoted 11 lines · SИbastien DuguИ
(quoted diff) +10 -0
+struct task_struct *good_sigevent(sigevent_t *event)
+{
+	struct task_struct *task = current->group_leader;
+
+	if ((event->sigev_notify & SIGEV_THREAD_ID) == SIGEV_THREAD_ID) {
+		task = find_task_by_pid(event->sigev_notify_thread_id);
+
+		if (!task || task->tgid != current->tgid)
+			return NULL;
+	} else if (event->sigev_notify == SIGEV_SIGNAL) {

No, no, we can't use "else" here,

Quoted 3 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+		if (event->sigev_signo <= 0 || event->sigev_signo > SIGRTMAX)

because we skip the check above in SIGEV_THREAD_ID case.

Quoted 6 lines

Right, will fix this.

Quoted 2 lines

This way any user can crash the kernel with a minimal effort.

Well I tried, no crash, just the signal failing to be delivered.

	sigaddset:

		set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW);

This writes to ->sig[event->sigev_signo / _NSIG_BPW] location, so we can corrupt the memory if ->sigev_signo > _NSIG.

Btw, since you are exporting this function, may I suggest to rename it? No, I can't suggest a better name :) But "good_sigevent" is a bit confusing imho.

Oleg.

#3 lore raw
Quoted 28 lines · On Fri, 26 Jan 2007 13:08:01 +0300 Oleg Nesterov <[email protected]> wrote:
Quoted 27 lines · S?bastien Dugu?
Quoted 15 lines · On Thu, 25 Jan 2007 18:43:24 +0300 Oleg Nesterov <[email protected]> wrote:

Review

Quoted 11 lines · SИbastien DuguИ
(quoted diff) +10 -0
+struct task_struct *good_sigevent(sigevent_t *event)
+{
+	struct task_struct *task = current->group_leader;
+
+	if ((event->sigev_notify & SIGEV_THREAD_ID) == SIGEV_THREAD_ID) {
+		task = find_task_by_pid(event->sigev_notify_thread_id);
+
+		if (!task || task->tgid != current->tgid)
+			return NULL;
+	} else if (event->sigev_notify == SIGEV_SIGNAL) {

No, no, we can't use "else" here,

Quoted 3 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+		if (event->sigev_signo <= 0 || event->sigev_signo > SIGRTMAX)

because we skip the check above in SIGEV_THREAD_ID case.

Right, will fix this.

Quoted 2 lines

This way any user can crash the kernel with a minimal effort.

Quoted 8 lines
Quoted 1 line

Well I tried, no crash, just the signal failing to be delivered.

	sigaddset:

		set->sig[sig / _NSIG_BPW] |= 1UL << (sig % _NSIG_BPW);

This writes to ->sig[event->sigev_signo / _NSIG_BPW] location, so we can corrupt the memory if ->sigev_signo > _NSIG.

Gawd, right.

Quoted 4 lines

Btw, since you are exporting this function, may I suggest to rename it? No, I can't suggest a better name :) But "good_sigevent" is a bit confusing imho.

I agree, there was a discussion concerning this a while back but nothing came
out of it and I left it as is.

I will try to find something more suggestive.

Thanks,

Sébastien.