From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: kernel virtual memory access (from app) does not generate segfault
Date: Tue, 20 Apr 2010 23:41:08 +0100 [thread overview]
Message-ID: <20100420224108.GA1432@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20100420223106.GQ11723@shareable.org>
On Tue, Apr 20, 2010 at 11:31:06PM +0100, Jamie Lokier wrote:
> Russell King - ARM Linux wrote:
> > User programs do not have permission to read kernel addresses. Trying to
> > do so _should_ generate a permission fault.
> >
> > > probably best to get Russell's opinion.
> >
> > if (user_mode(regs))
> > goto bad_area;
> >
> > should be sufficient, since userspace should not be accessing anything
> > above TASK_SIZE, except for the exception page, which will always be
> > mapped.
>
> Those two lines look good to me, or alternatively change
>
> if (addr < TASK_SIZE)
> to
> if (addr < TASK_SIZE || user_mode(regs))
>
> which lead to the same SIGSEGV by a more complicated route. That will
> continue to work if user-accessible pages are ever mapped using the
> vmalloc lazy method.
That'd be very disgusting if it ever happened.
> But a possible NAK: What happens when the kernel does get/put_user()
> on an address > TASK_SIZE with kernel-only mapping? user_mode()
> returns 0, so the LDRT will loop in the kernel, won't it?
No - the first data fault will cause the pgd entry to be copied, and then
the subsequent data fault will be a permission fault.
The difference between instruction faults and data faults is that we
always interpret instruction faults on pre-ARMv6 CPUs as a 'translation
fault' rather than a permission fault since they can't tell us what the
problem was.
next prev parent reply other threads:[~2010-04-20 22:41 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-20 9:14 kernel virtual memory access (from app) does not generate segfault Sasha Sirotkin
2010-04-20 9:34 ` Ben Dooks
2010-04-20 10:27 ` Dave P. Martin
2010-04-20 14:20 ` anfei
2010-04-20 17:09 ` Ben Dooks
2010-04-20 19:28 ` Russell King - ARM Linux
2010-04-20 22:31 ` Jamie Lokier
2010-04-20 22:41 ` Russell King - ARM Linux [this message]
2010-04-21 0:33 ` Jamie Lokier
2010-04-21 11:17 ` kernel virtual memory access (from app) does not generatesegfault Dave P. Martin
2010-04-21 12:43 ` anfei
2010-04-21 16:07 ` Dave P. Martin
2010-04-21 19:16 ` Jamie Lokier
2010-04-21 19:40 ` Russell King - ARM Linux
2010-04-21 21:00 ` Jamie Lokier
2010-04-21 19:36 ` Russell King - ARM Linux
2010-04-21 19:35 ` Russell King - ARM Linux
2010-04-21 21:24 ` Nicolas Pitre
2010-04-21 21:44 ` Russell King - ARM Linux
2010-04-21 21:54 ` Russell King - ARM Linux
2010-04-21 22:59 ` Nicolas Pitre
2010-04-22 10:56 ` Dave P. Martin
2010-04-22 12:29 ` anfei
2010-04-22 13:18 ` Dave P. Martin
2010-04-22 15:59 ` Jamie Lokier
2010-04-21 13:11 ` kernel virtual memory access (from app) does not generate segfault anfei
2010-04-21 19:45 ` Jamie Lokier
2010-06-08 13:29 ` anfei
2010-06-08 13:36 ` Russell King - ARM Linux
2010-06-08 14:19 ` anfei
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=20100420224108.GA1432@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.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).