Re: [PATCH] pid: Don't hash pid 0.
From: Oleg Nesterov
Date: Mon Jan 30 2006 - 04:41:00 EST
Eric W. Biederman wrote:
>
> --- a/kernel/pid.c
> +++ b/kernel/pid.c
> @@ -148,6 +148,9 @@ int fastcall attach_pid(task_t *task, en
> {
> struct pid *pid, *task_pid;
>
> + if (!nr)
> + goto out;
> +
> task_pid = &task->pids[type];
> pid = find_pid(type, nr);
> task_pid->nr = nr;
If nr == 0 then task_pid->nr is uninitialized, so
> @@ -169,6 +172,9 @@ static fastcall int __detach_pid(task_t
> int nr = 0;
>
> pid = &task->pids[type];
> + if (!pid->nr)
> + goto out;
this is unsafe.
Yes, INIT_TASK() sets pids[...].nr == 0, but this is fragile and at
least needs a comment.
Eric, Andrew, I think I have a better patch, will post in a minute.
Oleg.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/