From: Yonghong Song Subject: Re: [PATCH][v2] uprobes/x86: emulate push insns for uprobe on x86 Date: Tue, 14 Nov 2017 14:22:46 -0800 Message-ID: References: <20171110172546.3185266-1-yhs@fb.com> <20171113125956.GA11516@redhat.com> <6fdd9773-a0d0-7598-35d4-959bb3701d1b@fb.com> <20171114153424.GA17667@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Cc: , , , , , , , To: Oleg Nesterov Return-path: Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:57484 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751233AbdKNWX2 (ORCPT ); Tue, 14 Nov 2017 17:23:28 -0500 In-Reply-To: <20171114153424.GA17667@redhat.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 11/14/17 7:34 AM, Oleg Nesterov wrote: > On 11/13, Yonghong Song wrote: >> >> On 11/13/17 4:59 AM, Oleg Nesterov wrote: >>>> + switch (opc1) { >>>> + case 0x50: >>>> + reg_offset = offsetof(struct pt_regs, r8); >>>> + break; >>>> + case 0x51: >>>> + reg_offset = offsetof(struct pt_regs, r9); >>>> + break; >>>> + case 0x52: >>>> + reg_offset = offsetof(struct pt_regs, r10); >>>> + break; >>>> + case 0x53: >>>> + reg_offset = offsetof(struct pt_regs, r11); >>>> + break; >>>> + case 0x54: >>>> + reg_offset = offsetof(struct pt_regs, r12); >>>> + break; >>>> + case 0x55: >>>> + reg_offset = offsetof(struct pt_regs, r13); >>>> + break; >>>> + case 0x56: >>>> + reg_offset = offsetof(struct pt_regs, r14); >>>> + break; >>>> + case 0x57: >>>> + reg_offset = offsetof(struct pt_regs, r15); >>>> + break; >>>> + } >>>> +#else >>>> + return -ENOSYS; >>>> +#endif >>> >>> OK, but shouldn't we also return ENOSYS if CONFIG_X86_64=y but the probed task is 32bit? >> >> Just tested with a 32bit app on x86 box and segfaults. > > Hmm. How did you verify this? On a x86_32 box, I compiled the test case with static libraries (including static libc). And I then run this binary on x86_64 with uprobe enabled. You will need to install glibc-static package to make it work. > > Your v3 doesn't look right and it seems you misunderstood me... > >> Yes, we would need to >> return ENOSYS if the app is 32bit on 64bit system. > > Only if insn->length == 2. "push bp" and other valid 32bit push'es should be > emulated correctly or your patch is wrong. Confused... > >>> Or in this case uprobe_init_insn(x86_64 => false) should fail and push_setup_xol_ops() >>> won't be called? > > So it doesn't fail? > > Oleg. >