Re: [PATCH][v3] uprobes/x86: emulate push insns for uprobe on x86

2017-11-15 Thread Yonghong Song
On 11/15/17 9:07 AM, Oleg Nesterov wrote: On 11/15, Oleg Nesterov wrote: So please, check if uprobe_init_insn() fails or not in this case. After that we will know whether your patch needs the additional is_64bit_mm() check in push_setup_xol_ops() or not. OK, I did the check for you. uprobe

Re: [PATCH][v3] uprobes/x86: emulate push insns for uprobe on x86

2017-11-15 Thread Oleg Nesterov
On 11/15, Oleg Nesterov wrote: > > So please, check if uprobe_init_insn() fails or not in this case. After that > we will know whether your patch needs the additional is_64bit_mm() check in > push_setup_xol_ops() or not. OK, I did the check for you. uprobe_init_insn() doesn't fail but insn_init(x

Re: [PATCH][v3] uprobes/x86: emulate push insns for uprobe on x86

2017-11-15 Thread Oleg Nesterov
On 11/14, Yonghong Song wrote: > > > On 11/14/17 8:03 AM, Oleg Nesterov wrote: > >Ah, no, sizeof_long() is broken by the same reason, so you can't test it... > > Right. I hacked the emulate_push_stack (original name: push_ret_address) > with sizeof_long = 4, and 32bit binary uprobe works fine on x8

Re: [PATCH][v3] uprobes/x86: emulate push insns for uprobe on x86

2017-11-15 Thread Oleg Nesterov
On 11/14, Yonghong Song wrote: > > On 11/14/17 7:51 AM, Oleg Nesterov wrote: > > > >And test_thread_flag(TIF_ADDR32) is not right too. The caller is not > >necessarily the probed task. See is_64bit_mm(mm) in > >arch_uprobe_analyze_insn(). > > I printed out some statistics. On x86_64 platform, for

Re: [PATCH][v3] uprobes/x86: emulate push insns for uprobe on x86

2017-11-14 Thread Yonghong Song
On 11/14/17 8:03 AM, Oleg Nesterov wrote: On 11/14, Oleg Nesterov wrote: +#ifdef CONFIG_X86_64 + if (test_thread_flag(TIF_ADDR32)) + return -ENOSYS; +#endif No, this doesn't look right, see my previous email. You should do this check in the "if (insn->length == 2)" bran

Re: [PATCH][v3] uprobes/x86: emulate push insns for uprobe on x86

2017-11-14 Thread Yonghong Song
On 11/14/17 7:51 AM, Oleg Nesterov wrote: On 11/13, Yonghong Song wrote: +static int push_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn) +{ + u8 opc1 = OPCODE1(insn), reg_offset = 0; + + if (opc1 < 0x50 || opc1 > 0x57) + return -ENOSYS; + + if (i

Re: [PATCH][v3] uprobes/x86: emulate push insns for uprobe on x86

2017-11-14 Thread Oleg Nesterov
On 11/14, Oleg Nesterov wrote: > > > +#ifdef CONFIG_X86_64 > > + if (test_thread_flag(TIF_ADDR32)) > > + return -ENOSYS; > > +#endif > > No, this doesn't look right, see my previous email. You should do this > check in the "if (insn->length == 2)" branch below, "push bp" should be > emu

Re: [PATCH][v3] uprobes/x86: emulate push insns for uprobe on x86

2017-11-14 Thread Oleg Nesterov
On 11/13, Yonghong Song wrote: > > +static int push_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn) > +{ > + u8 opc1 = OPCODE1(insn), reg_offset = 0; > + > + if (opc1 < 0x50 || opc1 > 0x57) > + return -ENOSYS; > + > + if (insn->length > 2) > + retur

[PATCH][v3] uprobes/x86: emulate push insns for uprobe on x86

2017-11-13 Thread Yonghong Song
Uprobe is a tracing mechanism for userspace programs. Typical uprobe will incur overhead of two traps. First trap is caused by replaced trap insn, and the second trap is to execute the original displaced insn in user space. To reduce the overhead, kernel provides hooks for architectures to emulate