Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751576AbbEGQS1 (ORCPT ); Thu, 7 May 2015 12:18:27 -0400 Received: from www62.your-server.de ([213.133.104.62]:50791 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751337AbbEGQSW (ORCPT ); Thu, 7 May 2015 12:18:22 -0400 Message-ID: <554B9040.50802@iogearbox.net> Date: Thu, 07 May 2015 18:18:08 +0200 From: Daniel Borkmann User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Nicolas Schichan , Russell King , "David S. Miller" , Alexei Starovoitov , Mircea Gherzan , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH] ARM: net: delegate filter to kernel interpreter when imm_offset() return value can't fit into 12bits. References: <1431011661-10277-1-git-send-email-nschichan@freebox.fr> In-Reply-To: <1431011661-10277-1-git-send-email-nschichan@freebox.fr> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1481 Lines: 31 On 05/07/2015 05:14 PM, Nicolas Schichan wrote: > The ARM JIT code emits "ldr rX, [pc, #offset]" to access the literal > pool. #offset maximum value is 4095 and if the generated code is too > large, the #offset value can overflow and not point to the expected > slot in the literal pool. Additionally, when overflow occurs, bits of > the overflow can end up changing the destination register of the ldr > instruction. > > Fix that by detecting the overflow in imm_offset() and setting a flag > that is checked for each BPF instructions converted in > build_body(). As of now it can only be detected in the second pass. As > a result the second build_body() call can now fail, so add the > corresponding cleanup code in that case. > > Using multiple literal pools in the JITed code is going to require > lots of intrusive changes to the JIT code (which would better be done > as a feature instead of fix), just delegating to the kernel BPF > interpreter in that case is a more straight forward, minimal fix and > easy to backport. > > Signed-off-by: Nicolas Schichan Fix looks good to me. Fixes: ddecdfcea0ae ("ARM: 7259/3: net: JIT compiler for packet filters") Acked-by: Daniel Borkmann -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/