public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Oleg Nesterov <oleg@redhat.com>,
	Al Viro <viro@ZenIV.linux.org.uk>,
	Kees Cook <keescook@chromium.org>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	linux-s390@vger.kernel.org
Subject: Re: [PATCH 11/20] signal/s390: Use force_sigsegv in default_trap_handler
Date: Fri, 29 Oct 2021 14:32:36 -0500	[thread overview]
Message-ID: <87v91fhbjf.fsf@disp2133> (raw)
In-Reply-To: <87y26dp2hj.fsf@disp2133> (Eric W. Biederman's message of "Thu, 28 Oct 2021 10:56:24 -0500")

ebiederm@xmission.com (Eric W. Biederman) writes:

> Christian Borntraeger <borntraeger@de.ibm.com> writes:
>
>> Am 20.10.21 um 19:43 schrieb Eric W. Biederman:
>>> Reading the history it is unclear why default_trap_handler calls
>>> do_exit.  It is not even menthioned in the commit where the change
>>> happened.  My best guess is that because it is unknown why the
>>> exception happened it was desired to guarantee the process never
>>> returned to userspace.
>>>
>>> Using do_exit(SIGSEGV) has the problem that it will only terminate one
>>> thread of a process, leaving the process in an undefined state.
>>>
>>> Use force_sigsegv(SIGSEGV) instead which effectively has the same
>>> behavior except that is uses the ordinary signal mechanism and
>>> terminates all threads of a process and is generally well defined.
>>
>> Do I get that right, that programs can not block SIGSEGV from force_sigsegv
>> with a signal handler? Thats how I read the code. If this is true
>> then
>>
>> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
>
> 99% true, and it is what force_sigsegv(SIGSEGV) intends to do.
>
> Andy Lutormorski pointed at a race where a thread can call sigaction
> and change the signal handler after force_sigsegv has run but before
> the process dequeues the SIGSEGV.

I now have a simple patch that closes the sigaction vs force_sig race,
that I am adding to this set of changes.  So now I can say programs can
not block force_sigsegv(SIGSEGV) with a signal handler or any other
method.

Eric

>>> Cc: Heiko Carstens <hca@linux.ibm.com>
>>> Cc: Vasily Gorbik <gor@linux.ibm.com>
>>> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
>>> Cc: linux-s390@vger.kernel.org
>>> Fixes: ca2ab03237ec ("[PATCH] s390: core changes")
>>> History Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
>>> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
>>> ---
>>>   arch/s390/kernel/traps.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c
>>> index bcefc2173de4..51729ea2cf8e 100644
>>> --- a/arch/s390/kernel/traps.c
>>> +++ b/arch/s390/kernel/traps.c
>>> @@ -84,7 +84,7 @@ static void default_trap_handler(struct pt_regs *regs)
>>>   {
>>>   	if (user_mode(regs)) {
>>>   		report_user_fault(regs, SIGSEGV, 0);
>>> -		do_exit(SIGSEGV);
>>> +		force_sigsegv(SIGSEGV);
>>>   	} else
>>>   		die(regs, "Unknown program exception");
>>>   }
>>>

  reply	other threads:[~2021-10-29 19:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-20 17:32 [PATCH 00/20] exit cleanups Eric W. Biederman
2021-10-20 17:43 ` [PATCH 02/20] exit: Remove calls of do_exit after noreturn versions of die Eric W. Biederman
2021-10-21 16:02   ` Kees Cook
2021-10-21 16:25     ` Eric W. Biederman
2021-10-20 17:43 ` [PATCH 11/20] signal/s390: Use force_sigsegv in default_trap_handler Eric W. Biederman
2021-10-21 16:17   ` Kees Cook
2021-10-26  9:38   ` Christian Borntraeger
2021-10-28 15:56     ` Eric W. Biederman
2021-10-29 19:32       ` Eric W. Biederman [this message]
2021-10-20 21:51 ` [PATCH 21/20] signal: Replace force_sigsegv(SIGSEGV) with force_fatal_sig(SIGSEGV) Eric W. Biederman
2021-10-21  8:09   ` Geert Uytterhoeven
2021-10-21 13:33     ` Eric W. Biederman
2021-10-21  8:32   ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v91fhbjf.fsf@disp2133 \
    --to=ebiederm@xmission.com \
    --cc=borntraeger@de.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=keescook@chromium.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox