* Re: [Patch -tip] x86/ftrace: use uaccess in atomic context
2008-09-24 15:31 [Patch -tip] x86/ftrace: use uaccess in atomic context Frédéric Weisbecker
@ 2008-09-24 14:31 ` Steven Rostedt
2008-09-24 15:11 ` Ingo Molnar
1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2008-09-24 14:31 UTC (permalink / raw)
To: Frédéric Weisbecker; +Cc: Ingo Molnar, linux-kernel
On Wed, 24 Sep 2008, Fr?d?ric Weisbecker wrote:
> Hello,
>
> With last -tip I get this bug:
>
> [ 49.439988] in_atomic():0, irqs_disabled():1
> [ 49.440118] INFO: lockdep is turned off.
> [ 49.440118] Pid: 2814, comm: modprobe Tainted: G W 2.6.27-rc7 #4
> [ 49.440118] [<c01215e1>] __might_sleep+0xe1/0x120
> [ 49.440118] [<c01148ea>] ftrace_modify_code+0x2a/0xd0
> [ 49.440118] [<c01148a2>] ? ftrace_test_p6nop+0x0/0xa
> [ 49.440118] [<c016e80e>] __ftrace_update_code+0xfe/0x2f0
> [ 49.440118] [<c01148a2>] ? ftrace_test_p6nop+0x0/0xa
> [ 49.440118] [<c016f190>] ftrace_convert_nops+0x50/0x80
> [ 49.440118] [<c016f1d6>] ftrace_init_module+0x16/0x20
> [ 49.440118] [<c015498b>] load_module+0x185b/0x1d30
> [ 49.440118] [<c01767a0>] ? find_get_page+0x0/0xf0
> [ 49.440118] [<c02463c0>] ? sprintf+0x0/0x30
> [ 49.440118] [<c034e012>] ? mutex_lock_interruptible_nested+0x1f2/0x350
> [ 49.440118] [<c0154eb3>] sys_init_module+0x53/0x1b0
> [ 49.440118] [<c0352340>] ? do_page_fault+0x0/0x740
> [ 49.440118] [<c0104012>] syscall_call+0x7/0xb
> [ 49.440118] =======================
>
> It is because ftrace_modify_code() calls copy_to_user and
> copy_from_user.
> These functions have been inserted after guessing that there
> couldn't be any race condition but copy_[to/from]_user might
> sleep and __ftrace_update_code is called with local_irq_saved.
>
> These function have been inserted since this commit:
> d5e92e8978fd2574e415dc2792c5eb592978243d:
> "ftrace: x86 use copy from user function"
>
> Following is a patch which correct it.
> ---
> Adapt uaccess functions's use to atomic context in ftrace_modify_code()
> since we are in IRQ-off context: __ftrace_update_code() calls
> local_irq_save().
>
> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> ---
I had this exact patch sitting it my quilt queue. I thought I sent it out,
but it must have been lost in the noise.
Thanks,
Acked-by: Steven Rostedt <srostedt@redhat.com>
-- Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch -tip] x86/ftrace: use uaccess in atomic context
2008-09-24 15:31 [Patch -tip] x86/ftrace: use uaccess in atomic context Frédéric Weisbecker
2008-09-24 14:31 ` Steven Rostedt
@ 2008-09-24 15:11 ` Ingo Molnar
1 sibling, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2008-09-24 15:11 UTC (permalink / raw)
To: Frédéric Weisbecker; +Cc: linux-kernel, Steven Rostedt
* Frédéric Weisbecker <fweisbec@gmail.com> wrote:
> Hello,
>
> With last -tip I get this bug:
>
> [ 49.439988] in_atomic():0, irqs_disabled():1
> [ 49.440118] INFO: lockdep is turned off.
> [ 49.440118] Pid: 2814, comm: modprobe Tainted: G W 2.6.27-rc7 #4
> [ 49.440118] [<c01215e1>] __might_sleep+0xe1/0x120
> [ 49.440118] [<c01148ea>] ftrace_modify_code+0x2a/0xd0
> [ 49.440118] [<c01148a2>] ? ftrace_test_p6nop+0x0/0xa
> [ 49.440118] [<c016e80e>] __ftrace_update_code+0xfe/0x2f0
> [ 49.440118] [<c01148a2>] ? ftrace_test_p6nop+0x0/0xa
> [ 49.440118] [<c016f190>] ftrace_convert_nops+0x50/0x80
> [ 49.440118] [<c016f1d6>] ftrace_init_module+0x16/0x20
> [ 49.440118] [<c015498b>] load_module+0x185b/0x1d30
> [ 49.440118] [<c01767a0>] ? find_get_page+0x0/0xf0
> [ 49.440118] [<c02463c0>] ? sprintf+0x0/0x30
> [ 49.440118] [<c034e012>] ? mutex_lock_interruptible_nested+0x1f2/0x350
> [ 49.440118] [<c0154eb3>] sys_init_module+0x53/0x1b0
> [ 49.440118] [<c0352340>] ? do_page_fault+0x0/0x740
> [ 49.440118] [<c0104012>] syscall_call+0x7/0xb
> [ 49.440118] =======================
>
> It is because ftrace_modify_code() calls copy_to_user and
> copy_from_user.
> These functions have been inserted after guessing that there
> couldn't be any race condition but copy_[to/from]_user might
> sleep and __ftrace_update_code is called with local_irq_saved.
>
> These function have been inserted since this commit:
> d5e92e8978fd2574e415dc2792c5eb592978243d:
> "ftrace: x86 use copy from user function"
>
> Following is a patch which correct it.
applied to tip/tracing/ftrace, thanks Frédéric!
Ingo
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Patch -tip] x86/ftrace: use uaccess in atomic context
@ 2008-09-24 15:31 Frédéric Weisbecker
2008-09-24 14:31 ` Steven Rostedt
2008-09-24 15:11 ` Ingo Molnar
0 siblings, 2 replies; 3+ messages in thread
From: Frédéric Weisbecker @ 2008-09-24 15:31 UTC (permalink / raw)
To: Ingo Molnar; +Cc: linux-kernel, Steven Rostedt
[-- Attachment #1: Type: text/plain, Size: 1705 bytes --]
Hello,
With last -tip I get this bug:
[ 49.439988] in_atomic():0, irqs_disabled():1
[ 49.440118] INFO: lockdep is turned off.
[ 49.440118] Pid: 2814, comm: modprobe Tainted: G W 2.6.27-rc7 #4
[ 49.440118] [<c01215e1>] __might_sleep+0xe1/0x120
[ 49.440118] [<c01148ea>] ftrace_modify_code+0x2a/0xd0
[ 49.440118] [<c01148a2>] ? ftrace_test_p6nop+0x0/0xa
[ 49.440118] [<c016e80e>] __ftrace_update_code+0xfe/0x2f0
[ 49.440118] [<c01148a2>] ? ftrace_test_p6nop+0x0/0xa
[ 49.440118] [<c016f190>] ftrace_convert_nops+0x50/0x80
[ 49.440118] [<c016f1d6>] ftrace_init_module+0x16/0x20
[ 49.440118] [<c015498b>] load_module+0x185b/0x1d30
[ 49.440118] [<c01767a0>] ? find_get_page+0x0/0xf0
[ 49.440118] [<c02463c0>] ? sprintf+0x0/0x30
[ 49.440118] [<c034e012>] ? mutex_lock_interruptible_nested+0x1f2/0x350
[ 49.440118] [<c0154eb3>] sys_init_module+0x53/0x1b0
[ 49.440118] [<c0352340>] ? do_page_fault+0x0/0x740
[ 49.440118] [<c0104012>] syscall_call+0x7/0xb
[ 49.440118] =======================
It is because ftrace_modify_code() calls copy_to_user and
copy_from_user.
These functions have been inserted after guessing that there
couldn't be any race condition but copy_[to/from]_user might
sleep and __ftrace_update_code is called with local_irq_saved.
These function have been inserted since this commit:
d5e92e8978fd2574e415dc2792c5eb592978243d:
"ftrace: x86 use copy from user function"
Following is a patch which correct it.
---
Adapt uaccess functions's use to atomic context in ftrace_modify_code()
since we are in IRQ-off context: __ftrace_update_code() calls
local_irq_save().
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
[-- Attachment #2: trace.diff --]
[-- Type: text/plain, Size: 752 bytes --]
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 082d996..fd667f1 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -71,13 +71,13 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code,
* No real locking needed, this code is run through
* kstop_machine, or before SMP starts.
*/
- if (__copy_from_user(replaced, (char __user *)ip, MCOUNT_INSN_SIZE))
+ if (__copy_from_user_inatomic(replaced, (char __user *)ip, MCOUNT_INSN_SIZE))
return 1;
if (memcmp(replaced, old_code, MCOUNT_INSN_SIZE) != 0)
return 2;
- WARN_ON_ONCE(__copy_to_user((char __user *)ip, new_code,
+ WARN_ON_ONCE(__copy_to_user_inatomic((char __user *)ip, new_code,
MCOUNT_INSN_SIZE));
sync_core();
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-09-24 15:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-24 15:31 [Patch -tip] x86/ftrace: use uaccess in atomic context Frédéric Weisbecker
2008-09-24 14:31 ` Steven Rostedt
2008-09-24 15:11 ` Ingo Molnar
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.