linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Christophe LEROY <christophe.leroy@c-s.fr>
To: Michael Ellerman <mpe@ellerman.id.au>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>, Scott Wood <oss@buserror.net>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] powerpc/mm: Only read faulting instruction when necessary in do_page_fault()
Date: Mon, 24 Apr 2017 12:26:11 +0200	[thread overview]
Message-ID: <a41ff27c-fedc-6621-01ed-d25f4d0813d1@c-s.fr> (raw)
In-Reply-To: <87d1c2rwt3.fsf@concordia.ellerman.id.au>



Le 24/04/2017 à 11:15, Michael Ellerman a écrit :
> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>
>> diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
>> index 400f2d0d42f8..3d506589236c 100644
>> --- a/arch/powerpc/mm/fault.c
>> +++ b/arch/powerpc/mm/fault.c
>> @@ -356,8 +348,22 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
>>  		 * between the last mapped region and the stack will
>>  		 * expand the stack rather than segfaulting.
>>  		 */
>> -		if (address + 2048 < uregs->gpr[1] && !store_updates_sp(inst))
>> -			goto bad_area;
>> +		if (address + 2048 < uregs->gpr[1]) {
>> +			if (!inst) {
>
> That looks like it could lead to an infinite loop, if the instruction
> that caused the fault has been overwritten with NULL by another thread.

If the inst is NULL, store_updates_sp(inst) returns false so it jumps to 
bad_area_nosemaphore

Christophe

>
> Or did I miss something? (I only read the diff)
>
>> +				/*
>> +				 * We want to do this outside mmap_sem, because
>> +				 * reading code around nip can result in fault,
>> +				 * which will cause a deadlock when called with
>> +				 * mmap_sem held
>> +				 */
>> +				up_read(&mm->mmap_sem);
>> +				__get_user(inst,
>> +					   (unsigned int __user *)regs->nip);
>> +				if (!store_updates_sp(inst))
>> +					goto bad_area_nosemaphore;
>> +				goto retry;
>> +			}
>
>
> cheers
>

      reply	other threads:[~2017-04-24 10:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-24  8:28 [PATCH] powerpc/mm: Only read faulting instruction when necessary in do_page_fault() Christophe Leroy
2017-04-24  9:15 ` Michael Ellerman
2017-04-24 10:26   ` Christophe LEROY [this message]

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=a41ff27c-fedc-6621-01ed-d25f4d0813d1@c-s.fr \
    --to=christophe.leroy@c-s.fr \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=oss@buserror.net \
    --cc=paulus@samba.org \
    /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;
as well as URLs for NNTP newsgroup(s).