lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <m1obqyh960.fsf@fess.ebiederm.org>
Date:	Wed, 11 Apr 2012 03:09:27 -0700
From:	ebiederm@...ssion.com (Eric W. Biederman)
To:	Oleg Nesterov <oleg@...hat.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	David Howells <dhowells@...hat.com>,
	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] creds: kill __task_cred()->task_is_dead() validation

Oleg Nesterov <oleg@...hat.com> writes:

A small nit.  The subject should be:
"Remove task_is_dead from __task_cred() validation."
there is no method __task_cred()->task_is_dead().


> commit 8f92054e:
>
>     add the following validation condition:
>
>         task->exit_state >= 0
>
>     to permit the access if the target task is dead and therefore
>     unable to change its own credentials.
>
> OK, but afaics currently this can only help wait_task_zombie() which
> calls __task_cred() without rcu lock.
>
> Remove this validation and change wait_task_zombie() to use task_uid()
> instead. This means we do rcu_read_lock() only to shut up the lockdep,
> but we already do the same in, say, wait_task_stopped().
>
> task_is_dead() should die, task->exit_state != 0 means that this task
> has passed exit_notify(), only do_wait-like code paths should use this.
>
> Unfortunately, we can't kill task_is_dead() right now, it has already
> found the bugy users in drivers/staging/, the fix already exists.

I would say task_is_dead() has already acquired buggy users in
drivers/staging.

As for the patch itself, and the direction of removing task_is_dead().
It looks good from where I sit.

Reviewed-by: "Eric W. Biederman" <ebiederm@...ssion.com>

Eric


> Signed-off-by: Oleg Nesterov <oleg@...hat.com>
> ---
>  include/linux/cred.h |   10 +++-------
>  kernel/exit.c        |    2 +-
>  2 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/cred.h b/include/linux/cred.h
> index adadf71..1b64c72 100644
> --- a/include/linux/cred.h
> +++ b/include/linux/cred.h
> @@ -276,17 +276,13 @@ static inline void put_cred(const struct cred *_cred)
>   * @task: The task to query
>   *
>   * Access the objective credentials of a task.  The caller must hold the RCU
> - * readlock or the task must be dead and unable to change its own credentials.
> + * readlock.
>   *
>   * The result of this function should not be passed directly to get_cred();
>   * rather get_task_cred() should be used instead.
>   */
> -#define __task_cred(task)						\
> -	({								\
> -		const struct task_struct *__t = (task);			\
> -		rcu_dereference_check(__t->real_cred,			\
> -				      task_is_dead(__t));		\
> -	})
> +#define __task_cred(task)	\
> +	rcu_dereference((task)->real_cred)
>  
>  /**
>   * get_current_cred - Get the current task's subjective credentials
> diff --git a/kernel/exit.c b/kernel/exit.c
> index 4b4042f..7b36288 100644
> --- a/kernel/exit.c
> +++ b/kernel/exit.c
> @@ -1214,7 +1213,7 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
>  	unsigned long state;
>  	int retval, status, traced;
>  	pid_t pid = task_pid_vnr(p);
> -	uid_t uid = __task_cred(p)->uid;
> +	uid_t uid = task_uid(p);
>  	struct siginfo __user *infop;
>  
>  	if (!likely(wo->wo_flags & WEXITED))
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ