From patchwork Tue Nov 28 18:20:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 842248 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ymX631TKvz9sBd for ; Wed, 29 Nov 2017 05:20:42 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4C49BCD2; Tue, 28 Nov 2017 18:20:40 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id CDBD8CD1 for ; Tue, 28 Nov 2017 18:20:38 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 17AD714F for ; Tue, 28 Nov 2017 18:20:38 +0000 (UTC) X-Originating-IP: 208.91.3.26 Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 9F19717209D; Tue, 28 Nov 2017 19:20:35 +0100 (CET) From: Ben Pfaff To: dev@openvswitch.org Date: Tue, 28 Nov 2017 10:20:32 -0800 Message-Id: <20171128182032.22981-1-blp@ovn.org> X-Mailer: git-send-email 2.10.2 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff , Bhargava Shastry Subject: [ovs-dev] [PATCH] odp-util: Fix parsing corner case for encap_nsh() actions. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org When nothing matched, the code would loop forever. Found with libfuzzer. Reported-by: Bhargava Shastry Signed-off-by: Ben Pfaff Acked-by: Jan Scheurich --- lib/odp-util.c | 2 ++ tests/odp.at | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/lib/odp-util.c b/lib/odp-util.c index 45a890c46aa0..3e30b9ae7719 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -1870,6 +1870,8 @@ parse_odp_encap_nsh_action(const char *s, struct ofpbuf *actions) } continue; } + + return -EINVAL; } out: if (ret < 0) { diff --git a/tests/odp.at b/tests/odp.at index cd01b32d72ef..1a80322890eb 100644 --- a/tests/odp.at +++ b/tests/odp.at @@ -362,3 +362,11 @@ AT_CHECK_UNQUOTED([ovstest test-odp parse-actions < actions.txt], [0], [`cat actions.txt` ]) AT_CLEANUP + +AT_SETUP([OVS datapath actions parsing and formatting - invalid forms]) +dnl This caused a hang in older versions. +AT_CHECK([echo 'encap_nsh@:{@' | ovstest test-odp parse-actions +], [0], [dnl +odp_actions_from_string: error +]) +AT_CLEANUP