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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 25 Jun 2021 22:56:21 -0700
From:   Kees Cook <keescook@...omium.org>
To:     "Eric W. Biederman" <ebiederm@...ssion.com>
Cc:     Linus Torvalds <torvalds@...ux-foundation.org>,
        Al Viro <viro@...iv.linux.org.uk>,
        Michael Schmitz <schmitzmic@...il.com>,
        linux-arch <linux-arch@...r.kernel.org>,
        Jens Axboe <axboe@...nel.dk>, Oleg Nesterov <oleg@...hat.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Richard Henderson <rth@...ddle.net>,
        Ivan Kokshaysky <ink@...assic.park.msu.ru>,
        Matt Turner <mattst88@...il.com>,
        alpha <linux-alpha@...r.kernel.org>,
        Geert Uytterhoeven <geert@...ux-m68k.org>,
        linux-m68k <linux-m68k@...ts.linux-m68k.org>,
        Arnd Bergmann <arnd@...nel.org>, Tejun Heo <tj@...nel.org>
Subject: Re: [PATCH 8/9] signal/task_exit: Use start_task_exit in place of
 do_exit

On Thu, Jun 24, 2021 at 02:03:25PM -0500, Eric W. Biederman wrote:
> 
> Reuse start_task_exit_locked to implement start_task_exit.
> 
> Simplify the exit logic by having all exits go through get_signal.
> This simplifies the analysis of syncrhonization during exit and
> gurantees a full set of registers will be available for ptrace to
> examine at PTRACE_EVENT_EXIT.
> 
> Signed-off-by: "Eric W. Biederman" <ebiederm@...ssion.com>
> ---
>  include/linux/sched/signal.h |  1 +
>  kernel/exit.c                |  4 +++-
>  kernel/seccomp.c             |  2 +-
>  kernel/signal.c              | 12 ++++++++++++
>  4 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
> index a958381ba4a9..3f4e69c019b7 100644
> --- a/include/linux/sched/signal.h
> +++ b/include/linux/sched/signal.h
> @@ -430,6 +430,7 @@ static inline void ptrace_signal_wake_up(struct task_struct *t, bool resume)
>  
>  void start_group_exit(int exit_code);
>  void start_task_exit_locked(struct task_struct *task, int exit_code);
> +void start_task_exit(int exit_code);
>  
>  void task_join_group_stop(struct task_struct *task);
>  
> diff --git a/kernel/exit.c b/kernel/exit.c
> index 635f434122b7..51e0c82b3f7d 100644
> --- a/kernel/exit.c
> +++ b/kernel/exit.c
> @@ -889,7 +889,9 @@ EXPORT_SYMBOL(complete_and_exit);
>  
>  SYSCALL_DEFINE1(exit, int, error_code)
>  {
> -	do_exit((error_code&0xff)<<8);
> +	start_task_exit((error_code&0xff)<<8);
> +	/* get_signal will call do_exit */
> +	return 0;
>  }
>  
>  
> diff --git a/kernel/seccomp.c b/kernel/seccomp.c
> index b1c06fd1b205..e0c4c123a8bf 100644
> --- a/kernel/seccomp.c
> +++ b/kernel/seccomp.c
> @@ -1248,7 +1248,7 @@ static int __seccomp_filter(int this_syscall, const struct seccomp_data *sd,
>  			force_sig_seccomp(this_syscall, data, true);
>  		} else {
>  			if (action == SECCOMP_RET_KILL_THREAD)
> -				do_exit(SIGSYS);
> +				start_task_exit(SIGSYS);
>  			else
>  				start_group_exit(SIGSYS);
>  		}

Looks good, yeah.

> diff --git a/kernel/signal.c b/kernel/signal.c
> index afbc001220dd..63fda9b6bbf9 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -1424,6 +1424,18 @@ void start_task_exit_locked(struct task_struct *task, int exit_code)
>  	}
>  }
>  
> +void start_task_exit(int exit_code)
> +{
> +	struct task_struct *task = current;
> +	if (!fatal_signal_pending(task)) {
> +		struct sighand_struct *const sighand = task->sighand;
> +		spin_lock_irq(&sighand->siglock);
> +		if (!fatal_signal_pending(current))

efficiency nit: "task" instead of "current" here, yes?

> +			start_task_exit_locked(task, exit_code);
> +		spin_unlock_irq(&sighand->siglock);
> +	}
> +}
> +
>  struct sighand_struct *__lock_task_sighand(struct task_struct *tsk,
>  					   unsigned long *flags)
>  {
> -- 
> 2.20.1
> 

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ