From patchwork Thu Jan 17 18:22:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifeng Sun X-Patchwork-Id: 1026878 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="t9k4D07U"; 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 43gXd72YXqz9s3l for ; Fri, 18 Jan 2019 05:28:10 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id EA4CC23BB; Thu, 17 Jan 2019 18:28:08 +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 D894C22BF for ; Thu, 17 Jan 2019 18:22:19 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 8992576D for ; Thu, 17 Jan 2019 18:22:19 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id e5so5107319plb.5 for ; Thu, 17 Jan 2019 10:22:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=cy1hKsa52w4ecR6GO2AhbDZ64NqDyzTZJFHdklP4iis=; b=t9k4D07Ufd1yhovQg7/Q7VKq/Dv40NS8mRqJVdYn6eq4AfPsHtA1i94M2OtrM3bCA6 xY09jXve99ueEVUJ6OwaitrY2nnxHKx6Hzwj8qjo8lYPkzSFaYxcIvCuf3GUlBuyXeDK 6JPL9LI4xucLCQNKw5M24GHh+k927zhxrXSJ3bKOCDugO7ykF3FCCt0Bu587oz9bTaFc ZjeiyNarfE5/RzM+s2kxGtujC7A2Ua3v43CGaSeymxLvoznx8TivIakyR9kXN22+zKjT Oeol5XEVZOmRBDvUNaJEnJrZ33WKeI+3qIOrw3P1zxZ63oIMHr29DNcAx7kxq0xeIxYl bg3A== 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=cy1hKsa52w4ecR6GO2AhbDZ64NqDyzTZJFHdklP4iis=; b=Rr5klk3LrjrC+xlhSvk4iB24sPTGDVMwSGpIAweiSY8xBF+PFUJ2T0hXl+AJ8j8v8+ 0eSfYynhAeslDIg/zQyi3rSgGhe0zhsRPoybvTKQ0ea0iLiEYVa5/I5z56hjLb3UHaFU 2eBHVzb2qgHIP7417mD6dKWaZmeLr+OUlRJRhRQ/JynRQDx1yS39qAYB3nZ+SDhxbnYG OVdGtJqs8Vmg7yb4kqHtQWJlm7pOuX/HqrcI4TffRkDCVxR/iSVRxRmuJswjieINjZpn 9doDsf3p3B0uSi7IcMlBl94/KAdE+jw0waHd9HgDQmNIXLVdFjuzfCXufAieVxy/GAPf EWDQ== X-Gm-Message-State: AJcUukcdY13+wZob5lbHwSzP8fGiBkhBZiQgpd4lAHH29dXy4DeZahKY dB0IB7BqehthJCpJT7Cu+j3lsX2d X-Google-Smtp-Source: ALg8bN5Di61pxtTgI2YOimi015NGB0azaIB5bFJ/SiXrz/ELC16fhgCONRr7IUoYw60YDWrLLKXOZw== X-Received: by 2002:a17:902:161:: with SMTP id 88mr16302602plb.306.1547749338869; Thu, 17 Jan 2019 10:22:18 -0800 (PST) Received: from kern417.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id h185sm3164184pfg.143.2019.01.17.10.22.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Jan 2019 10:22:18 -0800 (PST) From: Yifeng Sun To: dev@openvswitch.org Date: Thu, 17 Jan 2019 10:22:12 -0800 Message-Id: <1547749332-23430-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 v3] odp-util: Fix a bug in parse_odp_push_nsh_action 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 In this piece of code, 'struct ofpbuf b' should always point to metadata so that metadata can be filled with values through ofpbuf operations, like ofpbuf_put_hex and ofpbuf_push_zeros. However, ofpbuf_push_zeros may change the data pointer of 'struct ofpbuf b' and therefore, metadata will not contain the expected values. This patch fixes it by changing ofpbuf_push_zeros to ofpbuf_put_zeros. Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10863 Signed-off-by: Yifeng Sun --- v1->v2: Fix a bug in previous version, thanks Ben! v2->v3: Use ofpbuf_put_zeros by previous discussion. lib/odp-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/odp-util.c b/lib/odp-util.c index 0491bed38a6c..a1c3e5bda550 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -2118,7 +2118,7 @@ parse_odp_push_nsh_action(const char *s, struct ofpbuf *actions) /* Pad metadata to 4 bytes. */ padding = PAD_SIZE(mdlen, 4); if (padding > 0) { - ofpbuf_push_zeros(&b, padding); + ofpbuf_put_zeros(&b, padding); } md_size = mdlen + padding; ofpbuf_uninit(&b);