Re: [PATCH] kernel/exit.c: pointer sighand could be uninitialized
From: Kees Cook
Date: Thu May 03 2018 - 00:50:51 EST
On Wed, May 2, 2018 at 6:48 PM, Yizhuo Zhai <yzhai003@xxxxxxx> wrote:
> Variable 'sighand' could be uninitialized if probe_kernel_address fails
> (-EFAULT). The later use in the if statement may lead to undefined behavior.
>
> Signed-off-by: yzhai003@xxxxxxx <yzhai003@xxxxxxx>
> ---
> kernel/exit.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/exit.c b/kernel/exit.c
> index f6cad39..a353bd1 100644
> --- a/kernel/exit.c
> +++ b/kernel/exit.c
> @@ -232,7 +232,7 @@ void release_task(struct task_struct *p)
> */
> struct task_struct *task_rcu_dereference(struct task_struct **ptask)
> {
> - struct sighand_struct *sighand;
> + struct sighand_struct *sighand = NULL;
> struct task_struct *task;
>
> /*
Better would probably be to check the return of probe_kernel_address()
and take appropriate action...
-Kees
--
Kees Cook
Pixel Security