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]
Date:	Wed, 13 Jun 2007 19:15:30 +0400
From:	Oleg Nesterov <oleg@...sign.ru>
To:	Roland McGrath <roland@...hat.com>
Cc:	Linus Torvalds <torvalds@...ux-foundation.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Linux Kernel <linux-kernel@...r.kernel.org>,
	Satoru Takeuchi <takeuchi_satoru@...fujitsu.com>,
	Benjamin Herrenschmidt <benh@...nel.crashing.org>
Subject: Re: [BUG] ptraced process waiting on syscall may return kernel internal errnos

Sorry for delay, I was completely offline,

On 06/06, Roland McGrath wrote:
> 
> [PATCH] Restrict clearing TIF_SIGPENDING
> 
> This patch should get a few birds.  It prevents sigaction calls from
> clearing TIF_SIGPENDING in other threads, which could leak -ERESTART*.
> It fixes ptrace_stop not to clear it, which done at the syscall exit
> stop could leak -ERESTART*.  It probably removes the harm from
> signalfd, at least assuming it never calls dequeue_signal on kernel
> threads that might have used block_all_signals.
> 
> Signed-off-by: Roland McGrath <roland@...hat.com>
> ---
>  kernel/signal.c |   40 ++++++++++++++++++++++++----------------
>  1 files changed, 24 insertions(+), 16 deletions(-)
> 
> diff --git a/kernel/signal.c b/kernel/signal.c
> index acdfc05..dc5797c 100644  
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -105,7 +105,11 @@ static int recalc_sigpending_tsk(struct 
>  		set_tsk_thread_flag(t, TIF_SIGPENDING);
>  		return 1;
>  	}
> -	clear_tsk_thread_flag(t, TIF_SIGPENDING);
> +	/*
> +	 * We must never clear the flag in another thread, or in current
> +	 * when it's possible the current syscall is returning -ERESTART*.
> +	 * So we don't clear it here, and only callers who know they should do.
> +	 */
>  	return 0;
>  }

This breaks cancel_freezing(). Somehow we should clear TIF_SIGPENDING for
kernel threads. Otherwise we may have subtle failures if try_to_freeze_tasks()
fails.

Also, whith this change do_sigaction()->recalc_sigpending_and_wake() doesn't
make sense any longer, yes?

> @@ -385,7 +391,8 @@ int dequeue_signal(struct task_struct *t
>  			}
>  		}
>  	}
> -	recalc_sigpending_tsk(tsk);
> +	if (likely(tsk == current))
> +		recalc_sigpending();

In theory, flush_signals(t) needs a similar change. However, it is always
called with t == current. Perhaps it makes sense to make it flush_signals(void) ?
Do you see any valid usage of flush_signals(t) when t != current ?

(Actually, imho the same is true for dequeue_signal(). Except for signalfd.c
 dequeue_signal() should operate on current. Perhaps it would be a bit cleaner
 to have dequeue_signal_tsk(tsk) and dequeue_signal(void), the latter does
 recalc_sigpending).

Oleg.

-
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