[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190621231232.259536faeea4b19cf39a7688@kernel.org>
Date: Fri, 21 Jun 2019 23:12:32 +0900
From: Masami Hiramatsu <mhiramat@...nel.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Thomas Gleixner <tglx@...utronix.de>,
LKML <linux-kernel@...r.kernel.org>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>,
Clark Williams <williams@...hat.com>,
Juri Lelli <juri.lelli@...il.com>,
Masami Hiramatsu <mhiramat@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: WARN_ON: userstacktrace on irq events
On Fri, 5 Apr 2019 09:32:09 -0400
Steven Rostedt <rostedt@...dmis.org> wrote:
> On Fri, 5 Apr 2019 10:12:27 +0200 (CEST)
> Thomas Gleixner <tglx@...utronix.de> wrote:
>
> > > BOOM! Warn on.
> > >
> > > Can we make that access_ok() call in the copy_stack_frame not trigger
> > > the warning just if we are in an interrupt?
> >
> > You really want to have access_ok_atomic() or such which does not have the
> > WARN and use that in copy_stack_frame(). That's fine here because the
> > actual copy is inside a pagefault disabled region.
>
> I was thinking the same.
>
> Masami, did you post patches to do something like this?
> "access_ok_inatomic()" or something?
Yeah, last month I sent
"x86/uaccess: Allow access_ok() in irq context if pagefault_disabled"
If you correctly disables the pagefault, access_ok() shouldn't warn it.
Ah, I see.
copy_stack_frame(const void __user *fp, struct stack_frame_user *frame)
{
int ret;
if (!access_ok(fp, sizeof(*frame))) <== this is out of pagefault_disable()!
return 0;
ret = 1;
pagefault_disable();
if (__copy_from_user_inatomic(frame, fp, sizeof(*frame)))
ret = 0;
pagefault_enable();
return ret;
}
How is below patch?
---
diff --git a/arch/x86/kernel/stacktrace.c b/arch/x86/kernel/stacktrace.c
index 2abf27d7df6b..36ff77c801f7 100644
--- a/arch/x86/kernel/stacktrace.c
+++ b/arch/x86/kernel/stacktrace.c
@@ -98,14 +98,11 @@ struct stack_frame_user {
static int
copy_stack_frame(const void __user *fp, struct stack_frame_user *frame)
{
- int ret;
+ int ret = 1;
- if (!access_ok(fp, sizeof(*frame)))
- return 0;
-
- ret = 1;
pagefault_disable();
- if (__copy_from_user_inatomic(frame, fp, sizeof(*frame)))
+ if (!access_ok(fp, sizeof(*frame)) ||
+ __copy_from_user_inatomic(frame, fp, sizeof(*frame)))
ret = 0;
pagefault_enable();
--
Masami Hiramatsu <mhiramat@...nel.org>
Powered by blists - more mailing lists