From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: print a fault message when attempting to write RO memory
Date: Thu, 16 Feb 2017 11:06:12 +0000 [thread overview]
Message-ID: <20170216110612.GA32039@leverpostej> (raw)
In-Reply-To: <20170216015408.12933-1-stephen.boyd@linaro.org>
Hi,
On Wed, Feb 15, 2017 at 05:54:08PM -0800, Stephen Boyd wrote:
> If a page is marked read only we should print out that fact,
> instead of printing out that there was a page fault. Right now we
> get a cryptic error message that something went wrong with an
> unhandled fault, but we don't evaluate the esr to figure out that
> it was a read/write permission fault.
>
> Instead of seeing:
>
> Unable to handle kernel paging request at virtual address ffff000008e460d8
> pgd = ffff800003504000
> [ffff000008e460d8] *pgd=0000000083473003, *pud=0000000083503003, *pmd=0000000000000000
> Internal error: Oops: 9600004f [#1] PREEMPT SMP
>
> we'll see:
>
> Internal error: Attempting to write read-only memory: 9600004f [#1] PREEMPT SMP
It's less than ideal to lose the fault address here. Arguably we should
also log that for the userspace cases.
It would also be nice to keep the table dump for the kernel fault case,
since dodgy page tables are a likely case there.
> @@ -331,6 +331,11 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
>
> if (!search_exception_tables(regs->pc))
> die("Accessing user space memory outside uaccess.h routines", regs, esr);
> + } else if (is_permission_fault(esr, regs)) {
> + if (esr & ESR_ELx_WNR)
> + die("Attempting to write read-only memory", regs, esr);
> + else
> + die("Attempting to read unreadable memory", regs, esr);
> }
We won't have looked at the exception tables yet, so won't this make
probe_kernel_{read,write}(), or any other extable users unsafe?
Could we update __do_kernel_fault() to report faults more thoroughly
instead?
Thanks,
Mark.
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
next prev parent reply other threads:[~2017-02-16 11:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-16 1:54 [PATCH] arm64: print a fault message when attempting to write RO memory Stephen Boyd
2017-02-16 11:06 ` Mark Rutland [this message]
2017-02-16 11:16 ` Mark Rutland
2017-02-16 19:06 ` Stephen Boyd
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=20170216110612.GA32039@leverpostej \
--to=mark.rutland@arm.com \
--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).