From: Michael Ellerman <mpe@ellerman.id.au>
To: Christophe Leroy <christophe.leroy@c-s.fr>,
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 19:15:20 +1000 [thread overview]
Message-ID: <87d1c2rwt3.fsf@concordia.ellerman.id.au> (raw)
In-Reply-To: <20170424082832.C0E8C6EAF5@localhost.localdomain>
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.
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
next prev parent reply other threads:[~2017-04-24 9:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-24 8:28 Christophe Leroy
2017-04-24 9:15 ` Michael Ellerman [this message]
2017-04-24 10:26 ` Christophe LEROY
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=87d1c2rwt3.fsf@concordia.ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=benh@kernel.crashing.org \
--cc=christophe.leroy@c-s.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--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
all inboxes | Powered by JetHome®