[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+55aFyVrrvDzUt0OU4d9YZM8C-N+ycSKEa3+-5nowUoZ=rb8w@mail.gmail.com>
Date: Sat, 21 Dec 2013 09:41:48 -0800
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: naveen yadav <yad.naveen@...il.com>,
Oleg Nesterov <oleg@...hat.com>,
Vaibhav Shinde <v.bhav.shinde@...il.com>,
Ajeet Yadav <ajeet.yadav.77@...il.com>
Cc: Tejun Heo <tj@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] secure unlock_task_sighand() call
Did you actually *see* the problem, or was this just from looking at the code?
I don't hate the patch, and it might be the right thing to do in any
case (just to avoid depending on subtle things), but this really *is*
subtle, and I'm adding Oleg to the participants since it is his code
(going back to 2006, no less).
We have coredump serialization in exit_mm() that I think *should* make
this all ok - if we still see p->mm matching our mm, I don't think it
should be able to get to __exit_signal() and make the sighand go away,
so the lock_task_sighand() shouldn't ever fail. But I might miss
something, and as mentioned the patch might be a good idea regardless
just to avoid overly subtle rules that can confuse people.
Oleg?
Linus
On Sat, Dec 21, 2013 at 1:55 AM, naveen yadav <yad.naveen@...il.com> wrote:
>
> When check code , we found below issue in zap_thread function().
>
> From 57bf616d0e20086d73122373baf799c675f4e3d5 Mon Sep 17 00:00:00 2001
> From: Ajeet Yadav <ajeet.yadav.77@...il.com>
> Date: Sat, 21 Dec 2013 14:45:48 +0530
> Subject: [PATCH] secure unlock_task_sighand() call
>
> Since the return value was not checked for lock_task_sighand(),
> there was a chance that spin_unlock_irqrestore being called
> from unlock_task_sighand gets called wihout actually acquire
> the lock, which inturn can lead to kernel crash.
>
> Signed-off-by: Ajeet Yadav <ajeet.yadav.77@...il.com>
> Signed-off-by: Vaibhav Shinde <v.bhav.shinde@...il.com>
>
> ---
> fs/coredump.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/fs/coredump.c b/fs/coredump.c
> index 6d8b4cd..447b02c 100644
> --- a/fs/coredump.c
> +++ b/fs/coredump.c
> @@ -357,9 +357,10 @@ static inline int zap_threads(struct task_struct
> *tsk, struct mm_struct *mm,
> do {
> if (p->mm) {
> if (unlikely(p->mm == mm)) {
> - lock_task_sighand(p, &flags);
> - nr += zap_process(p, exit_code);
> - unlock_task_sighand(p, &flags);
> + if (lock_task_sighand(p, &flags) {
> + nr += zap_process(p, exit_code);
> + unlock_task_sighand(p, &flags);
> + }
> }
> break;
> }
> --
> 1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists