From patchwork Thu Oct 25 21:41:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifeng Sun X-Patchwork-Id: 989373 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="HHUAYmH3"; 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 42h0vZ2THSz9sCV for ; Fri, 26 Oct 2018 08:42:02 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id BFD822297; Thu, 25 Oct 2018 21:41:58 +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 EC9352260 for ; Thu, 25 Oct 2018 21:41:56 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 933207CB for ; Thu, 25 Oct 2018 21:41:56 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id p5-v6so4466307plq.8 for ; Thu, 25 Oct 2018 14:41:56 -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=ftUGShdR0qL1PCgTl0/AgRMIgMNy5r+SioviOyO3OlU=; b=HHUAYmH3hCefdj/5S3y+K0aQMMafWgkpxCXEcj5Vsrsogax8vo+07R/bIu+E4sNKil h/cYd8HVlK4HbjVbyzRkdIQ3zNnV9iWKJEUfCegF2ZT0KnSS767anHHijjf6Qs8yCw9C WXupt8Vh0qTWD87NivEttkNOKiDL+/yxyMznGsilxSRjyZKm2poFbT1juQ6bX68YTotw DcwwBhLDjcPG5G2rY26E60HhPKmDr4nGuPHdxP7QNPXrKhlR10KL0WM58cbvJkvV+zd3 B3mwgRnEE2rv5TffDocXYApC8yMKJeDYj2Lvlc4+kjd8GXQ/l/bj5+gS41Ig81DoPr91 tokA== 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=ftUGShdR0qL1PCgTl0/AgRMIgMNy5r+SioviOyO3OlU=; b=D39mOEgDD6TmAkp9COrFCQgQVIpAhLBoJaRpBwuxSgmq3Qn0BDtzBQft4DuO7FHvhU J262joOdm/8++YKcTCpiXFOlz/4fyQ2iFtBmeoN/XWn1ibjGSZ6/AL3Db5dWS5CqWQ5b F+HJev/hXK44CuBqISxZQbupyBWggl4mrkXLRX1a2pYgLPSk0Xx5/0reMRcZsfJBpagc 3s8aME96OMw6nImR9cSArzChuGe8jHXYtSMAGK6IxNtyst/NQCZeRxyPa16AIn1wg26x 4N4fAOsJHQbIvEa53pSBGkkayiIjvSJU+UIiy+mei9w6LGStBv3MYHWQCTLeFr1Mngbf FY9w== X-Gm-Message-State: AGRZ1gJScLd8Y9A8W83EpMyMKx/s09IwTkZZlwIQkPVm15mB3z6yJaCt e+Y0BtLwDOvVLL1/GwSni7vg1Nic X-Google-Smtp-Source: AJdET5f48XXNdCuWi89JjaJvao7zsjN36sUBpCS6s8TQPsCztBpMaikpUGvw8jJvNteApj5wnyyNrQ== X-Received: by 2002:a17:902:e101:: with SMTP id cc1-v6mr827980plb.165.1540503715836; Thu, 25 Oct 2018 14:41:55 -0700 (PDT) Received: from kern417.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id n6-v6sm5800449pgj.63.2018.10.25.14.41.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 Oct 2018 14:41:55 -0700 (PDT) From: Yifeng Sun To: dev@openvswitch.org Date: Thu, 25 Oct 2018 14:41:50 -0700 Message-Id: <1540503710-23597-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] NSH: Fix NSH-related length macros that cause 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 In the filed of ver_flags_ttl_len of struct nshhdr, there are only 6 bits that are used to indicate header's total length in 4-byte words. Therefore, the max value for total is 252 (63x4), instead of 256 used in present code base. This patch fixes it. Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10855 Signed-off-by: Yifeng Sun --- datapath/linux/compat/include/net/nsh.h | 4 ++-- include/openvswitch/nsh.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/datapath/linux/compat/include/net/nsh.h b/datapath/linux/compat/include/net/nsh.h index ff3733d9032d..76894910cfcb 100644 --- a/datapath/linux/compat/include/net/nsh.h +++ b/datapath/linux/compat/include/net/nsh.h @@ -247,10 +247,10 @@ struct nshhdr { #define NSH_M_TYPE1_LEN 24 /* NSH header maximum Length. */ -#define NSH_HDR_MAX_LEN 256 +#define NSH_HDR_MAX_LEN 252 /* NSH context headers maximum Length. */ -#define NSH_CTX_HDRS_MAX_LEN 248 +#define NSH_CTX_HDRS_MAX_LEN 244 static inline struct nshhdr *nsh_hdr(struct sk_buff *skb) { diff --git a/include/openvswitch/nsh.h b/include/openvswitch/nsh.h index 55f59d636e5a..afed932fcb75 100644 --- a/include/openvswitch/nsh.h +++ b/include/openvswitch/nsh.h @@ -263,10 +263,10 @@ struct nsh_hdr { #define NSH_M_TYPE1_LEN 24 /* NSH header maximum Length. */ -#define NSH_HDR_MAX_LEN 256 +#define NSH_HDR_MAX_LEN 252 /* NSH context headers maximum Length. */ -#define NSH_CTX_HDRS_MAX_LEN 248 +#define NSH_CTX_HDRS_MAX_LEN 244 static inline uint16_t nsh_hdr_len(const struct nsh_hdr *nsh)