Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756747Ab3DZPkF (ORCPT ); Fri, 26 Apr 2013 11:40:05 -0400 Received: from mx0.aculab.com ([213.249.233.131]:40454 "HELO mx0.aculab.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753884Ab3DZPkD (ORCPT ); Fri, 26 Apr 2013 11:40:03 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Subject: RE: [RFC PATCH net-next 2/6] x86: bpf_jit_comp: support BPF_S_ANC_SECCOMP_LD_W instruction Date: Fri, 26 Apr 2013 16:38:09 +0100 Message-ID: In-Reply-To: <1366990066.8964.216.camel@edumazet-glaptop> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [RFC PATCH net-next 2/6] x86: bpf_jit_comp: support BPF_S_ANC_SECCOMP_LD_W instruction Thread-Index: Ac5CkoFFkLsaa4ipTmyGhl2v7JZRogAAL8XQ References: <1366962706-24204-1-git-send-email-xi.wang@gmail.com> <1366962706-24204-3-git-send-email-xi.wang@gmail.com> <1366985926.8964.190.camel@edumazet-glaptop> <1366990066.8964.216.camel@edumazet-glaptop> From: "David Laight" To: "Eric Dumazet" Cc: "Xi Wang" , "Daniel Borkmann" , "David S. Miller" , "Russell King" , "Heiko Carstens" , "Eric Dumazet" , "Will Drewry" , "Andrew Morton" , , Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id r3QFeBwK004465 Content-Length: 1207 Lines: 30 > > > >> + func = (u8 *)seccomp_bpf_load; > > > >> + t_offset = func - (image + addrs[i]); > > > >> + EMIT1_off32(0xbf, K); /* mov imm32,%edi */ > > > >> + EMIT1_off32(0xe8, t_offset); /* call seccomp_bpf_load */ > > > >> + break; > > > >> +#endif > > > > > > > > This seems seriously wrong to me. > > > > > > Can you elaborate? > > > > The 'call seccomp_bpf_load' needs a pc-relative offset, > > I assume that is what EMIT1_off32() generates. > > > > The other two instructions want an absolute 32 bit value... > > Hmm, this part is fine, we perform the relative adjustments in > t_offset = func - (image + addrs[i]); The call needs the displacement from the address of the instruction following the call. I can't imagine any way in which above can allow for the 5 byte 'mov imm32,%edi' instruction. I'd have thought there would be an EMIT1_imm32(). (I've written a lot of x86 asm in my days!) David ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?