From patchwork Wed Feb 24 02:15:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Denhardt X-Patchwork-Id: 387083 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.7 required=3.0 tests=BAYES_00, DATE_IN_PAST_12_24, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C61EEC433E6 for ; Wed, 24 Feb 2021 21:26:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8DE6264F0C for ; Wed, 24 Feb 2021 21:26:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235846AbhBXV0n (ORCPT ); Wed, 24 Feb 2021 16:26:43 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:54289 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234055AbhBXV0k (ORCPT ); Wed, 24 Feb 2021 16:26:40 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 7213A5C01A0; Wed, 24 Feb 2021 16:25:34 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 24 Feb 2021 16:25:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zenhack.net; h= message-id:in-reply-to:references:from:date:subject:to; s=fm2; bh=tnJKexTzKw0qVsJnjOY0FhPyQOVWwb55paZsLwXZnsI=; b=Sj8UOTKx5czL IwTyyi25XRQ1fpsEoEdt69hNcpSLmbG/QbiSlL0/HK69k1mVskwmHnCOttWf+Dvk QibSqVMPA8nEOgskaUxtYcaoa7fEpzF0h0zGFrdu1GHvUUoafKYl5mIoGR+K1hqW zr0w+Fzr03IhurgNyo3Xr3TvQwWVTOt8np8cp4Mpa9CaVnkdYQCe0uGG2asjFrCe u6Im8nTtvCJ2Fg4bycHQhUDG5pqQ01F9MKOR7mmXyNLUPloXGG77IGIg4rMI0lj3 CNtwXrOtEOFUzGLuasmMyrtF0k4mRcyh8yLBXYmr5w/I4jGHvelAGTIh35d1Mp4I Dh9I2vRUFQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=tnJKexTzKw0qVsJnjOY0FhPyQOVWw b55paZsLwXZnsI=; b=nC0XO5GxxbRygeckJ0aBZN9ghZJgwPi5QD35Fw4YzYaqp 6B9z/urOeL6gVN6D7hSCEYbcdv4SPx7hgx1+d4qyXw0rdy7olXKYIgWa7p/G+/FP A5HntTww0mhIj1lmPo/MM33WwkHZdgajDR1L7Cl6Izx/1rBlZO5IwnK+VA2nkE5z VrcydoUhAum0XRK9yDstMH8x8BPiOWVu4rp6tRgaggwE52Lourg3ZSAVWtNznGBQ FR/+tfRLn5obn/14jLPkeMzzFq6O492uMX/Cqs47svoWwaFKj1ZT75IjtBB3gYnm qD0hSPbJPFNsAkwhPeeKoLRS9PV/bkzKdjcZ+DfYA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrkeejgddugeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefkjghfhfffuffvsedttdertddttd dtnecuhfhrohhmpefkrghnucffvghnhhgrrhguthcuoehirghnseiivghnhhgrtghkrdhn vghtqeenucggtffrrghtthgvrhhnpeegleekvdehjefhudehhfefgfdtvdduveetveekhf ekueefhffhudegvdffgfduleenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecukfhp pedutddtrddtrdefjedrvddvudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehirghnseiivghnhhgrtghkrdhnvght X-ME-Proxy: Received: from localhost (pool-100-0-37-221.bstnma.fios.verizon.net [100.0.37.221]) by mail.messagingengine.com (Postfix) with ESMTPA id EB217108005C; Wed, 24 Feb 2021 16:25:33 -0500 (EST) X-Mailbox-Line: From a6b6c7516f5d559049d669968e953b4a8d7adea3 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Ian Denhardt Date: Tue, 23 Feb 2021 21:15:31 -0500 Subject: [PATCH 1/2] tools, bpf_asm: Hard error on out of range jumps. To: ast@kernel.org, daniel@iogearbox.net, bpf@vger.kernel.org, netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Per discussion at: https://lore.kernel.org/bpf/c964892195a6b91d20a67691448567ef528ffa6d.camel@linux.ibm.com/T/#t ...this was originally introduced as a warning due to concerns about breaking existing code, but a hard error probably makes more sense, especially given that concerns about breakage were only speculation. Signed-off-by: Ian Denhardt Acked-by: Ilya Leoshkevich --- tools/bpf/bpf_exp.y | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/bpf/bpf_exp.y b/tools/bpf/bpf_exp.y index 8d48e896be50..8d03e5245da5 100644 --- a/tools/bpf/bpf_exp.y +++ b/tools/bpf/bpf_exp.y @@ -549,9 +549,11 @@ static uint8_t bpf_encode_jt_jf_offset(int off, int i) { int delta = off - i - 1; - if (delta < 0 || delta > 255) - fprintf(stderr, "warning: insn #%d jumps to insn #%d, " + if (delta < 0 || delta > 255) { + fprintf(stderr, "error: insn #%d jumps to insn #%d, " "which is out of range\n", i, off); + exit(1); + } return (uint8_t) delta; }