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: <20201008135325.GG9995@redhat.com>
Date:   Thu, 8 Oct 2020 15:53:26 +0200
From:   Oleg Nesterov <oleg@...hat.com>
To:     Jens Axboe <axboe@...nel.dk>
Cc:     linux-kernel@...r.kernel.org, io-uring@...r.kernel.org,
        peterz@...radead.org, tglx@...utronix.de
Subject: Re: [PATCH 4/6] kernel: add support for TIF_NOTIFY_SIGNAL

On 10/05, Jens Axboe wrote:
>
>  static inline int signal_pending(struct task_struct *p)
>  {
> +#ifdef TIF_NOTIFY_SIGNAL
> +	/*
> +	 * TIF_NOTIFY_SIGNAL isn't really a signal, but it requires the same
> +	 * behavior in terms of ensuring that we break out of wait loops
> +	 * so that notify signal callbacks can be processed.
> +	 */
> +	if (unlikely(test_tsk_thread_flag(p, TIF_NOTIFY_SIGNAL)))
> +		return 1;
> +#endif
>  	return task_sigpending(p);
>  }

perhaps we can add test_tsk_thread_mask() later...

>  static inline void restore_saved_sigmask_unless(bool interrupted)
>  {
> -	if (interrupted)
> +	if (interrupted) {
> +#ifdef TIF_NOTIFY_SIGNAL
> +		WARN_ON(!test_thread_flag(TIF_SIGPENDING) &&
> +			!test_thread_flag(TIF_NOTIFY_SIGNAL));
> +#else
>  		WARN_ON(!test_thread_flag(TIF_SIGPENDING));
> -	else
> +#endif
> +	} else {
>  		restore_saved_sigmask();
> +	}

I'd suggest to simply do

	-	WARN_ON(!test_thread_flag(TIF_SIGPENDING));
	+	WARN_ON(!signal_pending(current);


> --- a/kernel/entry/kvm.c
> +++ b/kernel/entry/kvm.c
> @@ -8,6 +8,9 @@ static int xfer_to_guest_mode_work(struct kvm_vcpu *vcpu, unsigned long ti_work)
>  	do {
>  		int ret;
>  
> +		if (ti_work & _TIF_NOTIFY_SIGNAL)
> +			tracehook_notify_signal();

Can't really comment this change, but to me it would be more safe to
simply return -EINTR.

Or perhaps even better, treat _TIF_NOTIFY_SIGNAL and _TIF_SIGPENDING
equally:

	-	if (ti_work & _TIF_SIGPENDING) {
	+	if (ti_work & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) {
			kvm_handle_signal_exit(vcpu);
			return -EINTR;

Oleg.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ