posix_timer: remove wrong comment
PATCH 1/3 posix_timer: remove wrong comment
currently "The next step is hard to back out if there is an error." comment is not right, release_posix_timer() does put_pid().
--- kernel/posix-timers.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
kernel/posix-timers.c +0 -4
@@ -563,10 +563,6 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,if (error) goto out; -/* -* return the timer_id now. The next step is hard to -* back out if there is an error. -*/ if (copy_to_user (created_timer_id, &new_timer_id,sizeof (new_timer_id))) { error = -EFAULT ;
Signature · 1 line
1.6.6
PATCH 2/3 posix_timer: fix error path in timer_create
move CLOCK_DISPATCH(which_clock, timer_create, (new_timer)) after all possible EFAULT errors.
*_timer_create may allocate/get resources.
(for example posix_cpu_timer_create does get_task_struct)
--- kernel/posix-timers.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)
kernel/posix-timers.c +8 -8
@@ -555,14 +555,6 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock, goto out; } - it_id_set =IT_ID_SET ; - new_timer->it_id = (timer_t ) new_timer_id; - new_timer->it_clock = which_clock; - new_timer->it_overrun =-1 ; - error =CLOCK_DISPATCH (which_clock, timer_create, (new_timer)); -if (error) - goto out; -if (copy_to_user (created_timer_id, &new_timer_id,sizeof (new_timer_id))) { error = -EFAULT ;
@@ -593,6 +585,14 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock, new_timer->sigq->info.si_tid = new_timer->it_id; new_timer->sigq->info.si_code =SI_TIMER ; + it_id_set =IT_ID_SET ; + new_timer->it_id = (timer_t ) new_timer_id; + new_timer->it_clock = which_clock; + new_timer->it_overrun =-1 ; + error =CLOCK_DISPATCH (which_clock, timer_create, (new_timer)); +if (error) + goto out; +spin_lock_irq (¤t->sighand->siglock); new_timer->it_signal = current->signal;list_add (&new_timer->list, ¤t->signal->posix_timers);
Signature · 1 line
1.6.6
PATCH 3/3 posix_timer: move copy_to_user(created_timer_id) down in timer_create
According to Oleg Nesterov:
"We can move copy_to_user(created_timer_id) down after "if (timer_event_spec)" block too. (but before CLOCK_DISPATCH(), of course)."
--- kernel/posix-timers.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
kernel/posix-timers.c +6 -5
@@ -555,11 +555,6 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock, goto out; } -if (copy_to_user (created_timer_id, - &new_timer_id,sizeof (new_timer_id))) { - error = -EFAULT ; - goto out; - }if (timer_event_spec) {if (copy_from_user (&event, timer_event_spec,sizeof (event))) { error = -EFAULT ;
@@ -585,6 +580,12 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock, new_timer->sigq->info.si_tid = new_timer->it_id; new_timer->sigq->info.si_code =SI_TIMER ; +if (copy_to_user (created_timer_id, + &new_timer_id,sizeof (new_timer_id))) { + error = -EFAULT ; + goto out; + } + it_id_set =IT_ID_SET ; new_timer->it_id = (timer_t ) new_timer_id; new_timer->it_clock = which_clock;
Signature · 1 line
1.6.6
Re: [PATCH 2/3] posix_timer: fix error path in timer_create
In reply to Andrey VaginQuoted 31 lines · On Mon, 17 May 2010 17:41:43 +0400 Andrey Vagin <[email protected]> wrote:
move
CLOCK_DISPATCH(which_clock, timer_create, (new_timer))after all possible EFAULT errors.
*_timer_createmay allocate/get resources.
(for exampleposix_cpu_timer_createdoesget_task_struct)Signed-off-by Andrey Vagin <[email protected]>--- kernel/posix-timers.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)kernel/posix-timers.c +0
-8@@ -555,14 +555,6 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock, goto out; } - it_id_set =IT_ID_SET ; - new_timer->it_id = (timer_t ) new_timer_id; - new_timer->it_clock = which_clock; - new_timer->it_overrun =-1 ; - error =CLOCK_DISPATCH (which_clock, timer_create, (new_timer)); -if (error) - goto out; -if (copy_to_user (created_timer_id, &new_timer_id,sizeof (new_timer_id))) { error = -EFAULT ;
kernel/posix-timers.c SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock, · line 589
Quoted 5 lines
kernel/posix-timers.c +2
-0@@ -593,6 +585,14 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock, new_timer->sigq->info.si_tid = new_timer->it_id; new_timer->sigq->info.si_code =SI_TIMER ; + it_id_set =IT_ID_SET ; + new_timer->it_id = (timer_t ) new_timer_id;
This part should not be moved, this make possible leak of idr entry .
kernel/posix-timers.c SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock, · line 591
Quoted 2 lines
kernel/posix-timers.c +2
-0+ new_timer->it_clock = which_clock; + new_timer->it_overrun =-1 ;
I'm not so convenient of moving this as well.
kernel/posix-timers.c SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock, · line 598
Quoted 7 lines
kernel/posix-timers.c +4
-0+ error =CLOCK_DISPATCH (which_clock, timer_create, (new_timer)); +if (error) + goto out; +spin_lock_irq (¤t->sighand->siglock); new_timer->it_signal = current->signal;list_add (&new_timer->list, ¤t->signal->posix_timers);
Thanks
Stanislaw
Re: [PATCH 2/3] posix_timer: fix error path in timer_create
Quoted 4 lines · Stanislaw Gruszka
On Mon, 17 May 2010 17:41:43 +0400
Andrey Vagin<[email protected]> wrote:
Quoted 9 lines
kernel/posix-timers.c SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock, · line 590
Quoted 7 lines
kernel/posix-timers.c +2
-0@@ -593,6 +585,14 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock, new_timer->sigq->info.si_tid = new_timer->it_id; new_timer->sigq->info.si_code =SI_TIMER ; + it_id_set =IT_ID_SET ; + new_timer->it_id = (timer_t ) new_timer_id;This part should not be moved, this make possible leak of idr entry .
You are right. Pls, skip this patches too.
Quoted 18 lines
kernel/posix-timers.c SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
Quoted 4 lines
kernel/posix-timers.c +2
-0+ new_timer->it_clock = which_clock; + new_timer->it_overrun =-1 ;I'm not so convenient of moving this as well.
Quoted 8 lines
kernel/posix-timers.c +4
-0+ error =CLOCK_DISPATCH (which_clock, timer_create, (new_timer)); +if (error) + goto out; +spin_lock_irq (¤t->sighand->siglock);new_timer->it_signal = current->signal; list_add(&new_timer->list,¤t->signal->posix_timers);Thanks
Stanislaw