From patchwork Wed Feb 13 09:09:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li RongQing X-Patchwork-Id: 1041080 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=none (p=none dis=none) header.from=baidu.com 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 43ztz36wxzz9s4Z for ; Wed, 13 Feb 2019 20:10:23 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 5D65AEAB5; Wed, 13 Feb 2019 09:10:21 +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 82ECFE8F4 for ; Wed, 13 Feb 2019 09:09:18 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from tc-sys-mailedm05.tc.baidu.com (mx59.baidu.com [61.135.168.59]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id E40D85E4 for ; Wed, 13 Feb 2019 09:09:17 +0000 (UTC) Received: from localhost (cp01-cos-dev01.cp01.baidu.com [10.92.119.46]) by tc-sys-mailedm05.tc.baidu.com (Postfix) with ESMTP id 610311EBA001 for ; Wed, 13 Feb 2019 17:09:13 +0800 (CST) From: Li RongQing To: dev@openvswitch.org Date: Wed, 13 Feb 2019 17:09:13 +0800 Message-Id: <1550048953-18594-1-git-send-email-lirongqing@baidu.com> X-Mailer: git-send-email 1.7.1 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 Subject: [ovs-dev] [PATCH] conntrack: force packet length check in extract_l3_ipv4 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 Assure the packet size is larger than ip total length Signed-off-by: Li RongQing --- lib/conntrack.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/conntrack.c b/lib/conntrack.c index 5c43410ec..4a39327b3 100644 --- a/lib/conntrack.c +++ b/lib/conntrack.c @@ -1525,6 +1525,10 @@ extract_l3_ipv4(struct conn_key *key, const void *data, size_t size, return false; } + if (OVS_UNLIKELY(size < ntohs(ip->ip_tot_len))) { + return false; + } + if (IP_IS_FRAGMENT(ip->ip_frag_off)) { return false; }