From patchwork Tue Oct 9 22:39:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifeng Sun X-Patchwork-Id: 981553 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="floCoDTW"; dkim-atps=neutral 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 42VBxF2GxBz9s89 for ; Wed, 10 Oct 2018 09:39:29 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E3A41B5A; Tue, 9 Oct 2018 22:39:26 +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 099777A9 for ; Tue, 9 Oct 2018 22:39:26 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id B96194DA for ; Tue, 9 Oct 2018 22:39:25 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id k19-v6so1589329pfi.1 for ; Tue, 09 Oct 2018 15:39:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=GxvKwhH4Z3aIFgGwlOMsrc4skNAdQGKHHbbOsWbEvNw=; b=floCoDTWcWYPpJgAwZliiPueED14sN+hYcmdXG/fzoyHtaF1XEArOgl/4zkEF02mkw n9N6+d8JbdQ4x1ZF/K7IzP8SmF+w7wPyqROgFfyodfxTXuiJnwgx99pdykPxhg5Ohn9T VcsDaGeAWllPcyzmIFj7AQfano0FomBtXHeAFMSZcE06aQJQsb4lAVwhsHQMRInNwOai GmsT8oFLkRNotEqLdthMUFli07P6awtBsMb8WUPYCe5DeW8nWxEffyYFEZLbg0Bv4Ndd LNqOMQV5zQVpSkzwY3Ppuvo9yIC9kBCJxg7DlBmFPKxPdhfseE/zM3bAfV0vaAYHVy5d 499g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=GxvKwhH4Z3aIFgGwlOMsrc4skNAdQGKHHbbOsWbEvNw=; b=EfPwRcpPls1xSFj3LnILUl2tjAIxdXe3yzcKNryO0FU/UhiXhsjw+09XwC65NGyc+p MPCFW6CFkanovN2BhVRuGvEfvrp2dRA/2Mh2CnDJoDrlm9UEv8YUJg0rOjmAXxgKIvcm 10nf25GC6E7a9RZwynGRmBPKgUIzuGIh3rVlMVEcfiJ+G2oW+f0AyayF69DafkzU8vWo 9njrCQPp0DeJPzQrhP3ZYOGVNhPI0ew7gwBhHdVzlt/fzWHC7jVAeIpqsANV7wat6xAA s4jo194Db8xsqGbS9Sf4jNKZm7q085Mf/HcSDAuxxtah+oz57XrCLBOd1yfx0hfMhN20 LbMw== X-Gm-Message-State: ABuFfohL7Mz1db9zsmCa/bwltOYCR06/l40rNI3BvlZmNDwqD9KcYO9S R8T9uBOXmwzeIioyZL249DCqR9ic X-Google-Smtp-Source: ACcGV63tvGr3OTBbIvgrDSDvlaW8gN+hrapLyV5DNfdoBXCZop+D4elzI5FFCFiPZFbWxKNmOq+ENA== X-Received: by 2002:a63:c912:: with SMTP id o18-v6mr27125661pgg.331.1539124765071; Tue, 09 Oct 2018 15:39:25 -0700 (PDT) Received: from kern417.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id n13-v6sm24127537pgr.73.2018.10.09.15.39.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Oct 2018 15:39:24 -0700 (PDT) From: Yifeng Sun To: dev@openvswitch.org Date: Tue, 9 Oct 2018 15:39:17 -0700 Message-Id: <1539124758-7478-1-git-send-email-pkusunyifeng@gmail.com> X-Mailer: git-send-email 2.7.4 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 1/2] odp-util: Fix a bug that causes stack overflow 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 ofpbuf_put_hex doesn't know buf's length and only checks buf's content to process. This is dangerous. This patch fixes it. Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10865 Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10863 Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10855 Signed-off-by: Yifeng Sun --- lib/odp-util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/odp-util.c b/lib/odp-util.c index 7705bb30ae21..d482d5bcf968 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -2107,6 +2107,7 @@ parse_odp_push_nsh_action(const char *s, struct ofpbuf *actions) if (ovs_scan_len(s, &n, "md2=0x%511[0-9a-fA-F]", buf)) { ofpbuf_use_stub(&b, metadata, NSH_CTX_HDRS_MAX_LEN); + buf[n - 6] = '\0'; ofpbuf_put_hex(&b, buf, &mdlen); /* Pad metadata to 4 bytes. */ padding = PAD_SIZE(mdlen, 4);