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: 387112 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=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 6296AC433E0 for ; Wed, 24 Feb 2021 02:43:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1831F64E83 for ; Wed, 24 Feb 2021 02:43:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232608AbhBXCn2 (ORCPT ); Tue, 23 Feb 2021 21:43:28 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:54331 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232069AbhBXCnT (ORCPT ); Tue, 23 Feb 2021 21:43:19 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 1C00F5C00F2; Tue, 23 Feb 2021 21:42:14 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 23 Feb 2021 21:42:14 -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=HjlAt4q1I57gcSh+6fE9t+TZP+zh66/1nuPwmJTGjfA=; b=YGmTgec/Bo4t Aoa035nUXoPMv1AwqNPT3X+f5Rygm+xIeSXV0TgBx1ZDbIPbj9n2fDxTTOV34jwm oseEUGc7ak3gcakN6OYuvbPgJH4BBAyR9OZnGFGsD0z+YXXWgF4fMmQGlAxwb6GF GuqugMwjiHYsGSMaEhCNM2cT5PTLhwB3X23oMeJN12umntbCzt6JIsoOPHmmNoOl xj1UTMyNu8yTXU/bTEClR0dGojgstOKzfkeKUYsHAljMFMejWdpkOzclRodvQleU 0pFJwVZM4YcdLAVqQuYAdw/YsZ8+D7rCkKjqnfSEchysgZwMiLGgcJH0FqLB2qKh dxYNp+ZGcQ== 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=HjlAt4q1I57gcSh+6fE9t+TZP+zh6 6/1nuPwmJTGjfA=; b=cmBbvmnHrfZv3dgdR+su34Sr4sDFFGJWpOiSWurjTmvQj 2yHoBSTMGbpjzWBgQGkwKpsHLyjzXPh7wgiNbF3zIwKneIsuf0v77y3eVpCiyr/q W84qsjR3gBCKa9NXZMEvEVAGp0KLDgMOL3HxS1xgC2zjVY2PvGJme9UM+k2vLfWo kyIkzuNp2tvI7WkFgZq1OuNl7yawrBTjhR0vdtOYnCeetygty3Y+RSubgTxal3/1 rYN8nbiK3EKjwd8M6TDPIODVAvYLXgRiyNtPz+VguoGZ0Iq8+me+rAUz9VPxqMfy NX9JIQ4AIihRBxMzNyegb9n4qb3TpGWczVxVeGhqg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrkeeigdegiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepkfgjfhfhfffuvfestddtredttddttd enucfhrhhomhepkfgrnhcuffgvnhhhrghrughtuceoihgrnhesiigvnhhhrggtkhdrnhgv theqnecuggftrfgrthhtvghrnhepgeelkedvheejhfduhefhfefgtddvudevteevkefhke eufefhhfdugedvfffgudelnecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenucfkphep uddttddrtddrfeejrddvvddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepihgrnhesiigvnhhhrggtkhdrnhgvth 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 CACF91080063; Tue, 23 Feb 2021 21:42:13 -0500 (EST) X-Mailbox-Line: From af571eef0bc5d33180879c0c81a7d1b26431b915 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. --- 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; } From patchwork Wed Feb 24 02:24:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Denhardt X-Patchwork-Id: 387617 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=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 095A8C433DB for ; Wed, 24 Feb 2021 02:43:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B41C964E7A for ; Wed, 24 Feb 2021 02:43:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232917AbhBXCnb (ORCPT ); Tue, 23 Feb 2021 21:43:31 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:49033 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232698AbhBXCnZ (ORCPT ); Tue, 23 Feb 2021 21:43:25 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id A97B65C0113; Tue, 23 Feb 2021 21:42:18 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 23 Feb 2021 21:42:18 -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=zX7JBPLIHAV2HMYc9beglbBAlWe9br7l4Md06RPvYow=; b=efjJ6OteR33d tzsN4LRW/Gl14AmksIb2CKhYpIcWlNIBPY+EVDZ4KFlXbANHmHSy5jwcTdKuxQLe n1AKAdU0ZaFwzRv6GnwjwlSo9FVzcGPupf2GgY/jxqP8m0kfp/hBZPmkdoehjnIj xFK+FGtDgb1KUBORjj42uCbrD9btDQgMnBG44Po9WJqGYfsHOluHitb0wAhSXgXy H3/h5NO7x3mrIxZHx4wv27Y2GZ+epSRLa92YeCVCvfl4r/PwrQY+6vPdxo/hAH8J IoAKvxu2TknB/vZer6tOtpxT6di7/v9hc4HZAWT2BsmZ/zDsqBEuydDBnpr/LdkJ NI4wds898A== 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=zX7JBPLIHAV2HMYc9beglbBAlWe9b r7l4Md06RPvYow=; b=V8OErlgmH/t6PqBteEXF7aORvUnsedYPmHyTSDUx90vHj +AWzAoaV3iH1g1+ZYL1QMDE29vwQ7VBd6Bwd5Fzoe2jdchvZJX9rYfgbxj8iAvjx yKsGeq7fM/RprfNudqSKhw2xo95L7GBu2L+j64nU8453xfEN6N0QOK39P5I1YyrT UbFf7RuFv7D6QvL6Lpxh9iO4ARbvzX6oUvdVKNk9rdLoyzT3LuIhijCUsvRgonjL bBxGbDoN9aqV1i+9YMEw+5K+NZJPFPBq6KycOebGqbu0JDUabv+6881PDk/e24Rl ZJ7yFW4WPIxpV1Ei9d0Ycjvpo3IunrksuvwdMxPJw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrkeeigdegiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepkfgjfhfhfffuvfestddtredttddttd enucfhrhhomhepkfgrnhcuffgvnhhhrghrughtuceoihgrnhesiigvnhhhrggtkhdrnhgv theqnecuggftrfgrthhtvghrnhepleelgefggfeuvdfgleegffeludduledttefggeeivd ekgeeffeeiffduvdejjeffnecukfhppedutddtrddtrdefjedrvddvudenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehirghnseiivghnhhgrtg hkrdhnvght 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 6938824005D; Tue, 23 Feb 2021 21:42:18 -0500 (EST) X-Mailbox-Line: From edb7c1985e446f6dd4ad875f39605bb2968d9920 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Ian Denhardt Date: Tue, 23 Feb 2021 21:24:00 -0500 Subject: [PATCH 2/2] tools, bpf_asm: exit non-zero on errors. 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 ...so callers can correctly detect failure. --- tools/bpf/bpf_exp.y | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/bpf/bpf_exp.y b/tools/bpf/bpf_exp.y index 8d03e5245da5..dfb7254a24e8 100644 --- a/tools/bpf/bpf_exp.y +++ b/tools/bpf/bpf_exp.y @@ -185,13 +185,13 @@ ldx | OP_LDXB number '*' '(' '[' number ']' '&' number ')' { if ($2 != 4 || $9 != 0xf) { fprintf(stderr, "ldxb offset not supported!\n"); - exit(0); + exit(1); } else { bpf_set_curr_instr(BPF_LDX | BPF_MSH | BPF_B, 0, 0, $6); } } | OP_LDX number '*' '(' '[' number ']' '&' number ')' { if ($2 != 4 || $9 != 0xf) { fprintf(stderr, "ldxb offset not supported!\n"); - exit(0); + exit(1); } else { bpf_set_curr_instr(BPF_LDX | BPF_MSH | BPF_B, 0, 0, $6); } } ; @@ -472,7 +472,7 @@ static void bpf_assert_max(void) { if (curr_instr >= BPF_MAXINSNS) { fprintf(stderr, "only max %u insns allowed!\n", BPF_MAXINSNS); - exit(0); + exit(1); } } @@ -522,7 +522,7 @@ static int bpf_find_insns_offset(const char *label) if (ret == -ENOENT) { fprintf(stderr, "no such label \'%s\'!\n", label); - exit(0); + exit(1); } return ret;