From: psodagud@codeaurora.org (Sodagudi Prasad)
To: linux-arm-kernel@lists.infradead.org
Subject: <Query> Looking more details and reasons for using orig_add_limit.
Date: Tue, 14 Feb 2017 21:52:30 -0800 [thread overview]
Message-ID: <def87360266193184dc013a055ec3869@codeaurora.org> (raw)
Hi All,
Would like to understand the reasons behind using the orig_add_limit
variable in the following code. Can you please share more details ?
"arch/arm64/mm/fault.c"
static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
struct pt_regs *regs)
{
?
?
?
if (addr < USER_DS && is_permission_fault(esr, regs)) {
=====>> condition_1
/* regs->orig_addr_limit may be 0 if we entered from EL0
*/
if (regs->orig_addr_limit == KERNEL_DS)
=====>> condition_2
die("Accessing user space memory with
fs=KERNEL_DS", regs, esr);
if (is_el1_instruction_abort(esr))
die("Attempting to execute userspace memory",
regs, esr);
if (!search_exception_tables(regs->pc))
die("Accessing user space memory outside
uaccess.h routines", regs, esr);
}
When any sys call is made from user space orig_addr_limit will be zero
and after that driver is calling set_fs(KERNEL_DS) and then
copy_to_user() to user space memory. If there is permission fault for
user space address the above condition is leading to kernel crash.
Because orig_add_limit is having KERNEL_DS as set_fs called before
copy_to_user().
1) So I would like to understand that, is that user space pointer
leading to permission fault not correct(condition_1) in this scenario?
2) Are there any corner cases where these if conditions (condition_1 and
condition2) would lead to kernel crash ?
3) What are all scenarios these if conditions (condition_1 and
condition2) would like to take care?
-Thanks, Prasad
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum,
Linux Foundation Collaborative Project
WARNING: multiple messages have this Message-ID (diff)
From: Sodagudi Prasad <psodagud@codeaurora.org>
To: catalin.marinas@arm.com, will.deacon@arm.com,
"<mark.rutland"@arm.com, james.morse@arm.com,
akpm@linux-foundation.org, sandeepa.s.prabhu@gmail.com,
sandeepa.s.prabhu@gmail.com, shijie.huang@arm.com
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, psodagud@codeaurora.org
Subject: <Query> Looking more details and reasons for using orig_add_limit.
Date: Tue, 14 Feb 2017 21:52:30 -0800 [thread overview]
Message-ID: <def87360266193184dc013a055ec3869@codeaurora.org> (raw)
Hi All,
Would like to understand the reasons behind using the orig_add_limit
variable in the following code. Can you please share more details ?
"arch/arm64/mm/fault.c"
static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
struct pt_regs *regs)
{
…
…
…
if (addr < USER_DS && is_permission_fault(esr, regs)) {
=====>> condition_1
/* regs->orig_addr_limit may be 0 if we entered from EL0
*/
if (regs->orig_addr_limit == KERNEL_DS)
=====>> condition_2
die("Accessing user space memory with
fs=KERNEL_DS", regs, esr);
if (is_el1_instruction_abort(esr))
die("Attempting to execute userspace memory",
regs, esr);
if (!search_exception_tables(regs->pc))
die("Accessing user space memory outside
uaccess.h routines", regs, esr);
}
When any sys call is made from user space orig_addr_limit will be zero
and after that driver is calling set_fs(KERNEL_DS) and then
copy_to_user() to user space memory. If there is permission fault for
user space address the above condition is leading to kernel crash.
Because orig_add_limit is having KERNEL_DS as set_fs called before
copy_to_user().
1) So I would like to understand that, is that user space pointer
leading to permission fault not correct(condition_1) in this scenario?
2) Are there any corner cases where these if conditions (condition_1 and
condition2) would lead to kernel crash ?
3) What are all scenarios these if conditions (condition_1 and
condition2) would like to take care?
-Thanks, Prasad
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum,
Linux Foundation Collaborative Project
next reply other threads:[~2017-02-15 5:52 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-15 5:52 Sodagudi Prasad [this message]
2017-02-15 5:52 ` <Query> Looking more details and reasons for using orig_add_limit Sodagudi Prasad
2017-02-15 11:38 ` Will Deacon
2017-02-15 11:38 ` Will Deacon
2017-02-15 12:09 ` James Morse
2017-02-15 12:09 ` James Morse
2017-02-15 21:12 ` Sodagudi Prasad
2017-02-15 21:12 ` Sodagudi Prasad
2017-02-16 10:39 ` James Morse
2017-02-16 10:39 ` James Morse
2017-02-21 14:20 ` Sodagudi Prasad
2017-02-21 14:20 ` Sodagudi Prasad
2017-02-22 19:53 ` Laurent Pinchart
2017-02-22 19:53 ` Laurent Pinchart
2017-02-22 20:25 ` Mauro Carvalho Chehab
2017-02-22 20:25 ` Mauro Carvalho Chehab
2017-02-23 0:25 ` Laurent Pinchart
2017-02-23 0:25 ` Laurent Pinchart
2017-02-22 19:53 ` Mauro Carvalho Chehab
2017-02-22 19:53 ` Mauro Carvalho Chehab
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=def87360266193184dc013a055ec3869@codeaurora.org \
--to=psodagud@codeaurora.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.