From patchwork Wed Jul 11 16:05:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrell Ball X-Patchwork-Id: 942594 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="UPWv8/HD"; 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 41QkSB5w1tz9rxs for ; Thu, 12 Jul 2018 02:05:30 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E46BCE8F; Wed, 11 Jul 2018 16:05:22 +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 E6F39E8D for ; Wed, 11 Jul 2018 16:05:21 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id A3853FC for ; Wed, 11 Jul 2018 16:05:21 +0000 (UTC) Received: by mail-pf0-f195.google.com with SMTP id b17-v6so18713406pfi.0 for ; Wed, 11 Jul 2018 09:05:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=stmBOnjzEvpAqhNRMefshxaSiCrp/M0+bbEQir7s6Gc=; b=UPWv8/HDgoCirPH64PV1Uu40e17zzkPHTVgxhdHVFN39TxQ2rmkGx7LHgZ7rjDlEww XZLQUjUG3qxhhaxrhdMIIcefz1/HnUZLhnO/ajPih0JTbTbpkr2Xvt82eNqL9HCKw/q3 a6yjfE8YTljrKH8YSnRnMrwKX/VJA1Sig3JhlZ5SmeL+FY+CoyOjw4Pci+bsYiN5CGQP /SJvCr81K2HhQeqrV11S75H4juHS8yL5ToRYQYXKQL4obZ+hd/ubb3+OJpnr0rg3hzZa 9ihkJmN1oWXXgA96JTi3cam3lb622gAQTM9xvPtv716d7pi/zvko8Ystk+EsIfZ8YxjD DSfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=stmBOnjzEvpAqhNRMefshxaSiCrp/M0+bbEQir7s6Gc=; b=JwrGMKZnmNKAkoKYG10kvCWEnJJStCiJ6ryssFPxfnMu8/JTCD2/dct7DkckHl1St7 Quo4esUimX6LWDLJbBpIoS8qhR89MJA697ekYqo+PpjGOnEjHxrtYJkUzk4bHc2fOzVe 9sze5ZuKKIVbRzxByCyOTsgyEPMGcdHo4auGwETXlq/kAHmKsXHNXkCfnrdJgW56+Qli bSlUsNEb1XIFv6F7Kc8Gpi5yvfz8+EHYpOZj/MXD3ELplbBRdLFbv53vO3iIeL1t7WRK VWUMsYMLYgvsYFFmQzMMkNLl1m430Rr+quzrBytPahVmBOHEg2IcyVadJJ6M7BdVoP/2 SVWA== X-Gm-Message-State: APt69E1OGio8kAaFCPTq92+lxQmmnCX2e2xfG3mSqs1bjjyJnO0hlB53 Lnw7agfvLdd1ehLqkXqTRyc= X-Google-Smtp-Source: AAOMgpeCE3EcTmGpE9LdzhOhc9tkpWT+VLf0hWfuMnuJXPKReL5ZD2raPpE1z9tF0Ef/QtJG69wwVw== X-Received: by 2002:a62:444d:: with SMTP id r74-v6mr30334791pfa.96.1531325121339; Wed, 11 Jul 2018 09:05:21 -0700 (PDT) Received: from ubuntu.localdomain (c-73-162-236-45.hsd1.ca.comcast.net. [73.162.236.45]) by smtp.gmail.com with ESMTPSA id g2-v6sm36465105pgn.92.2018.07.11.09.05.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jul 2018 09:05:20 -0700 (PDT) From: Darrell Ball To: dlu998@gmail.com, dev@openvswitch.org Date: Wed, 11 Jul 2018 09:05:11 -0700 Message-Id: <1531325111-58795-1-git-send-email-dlu998@gmail.com> X-Mailer: git-send-email 1.9.1 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [patch v2 branch 2.8] conntrack: Fix use after free for FTP control case. 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 conn_update_state() returns true, conn has been freed, so skip calling handle_ftp_ctl() with this conn and instead follow code path for new connections. Fixes: bd5e81a0e596 ("Userspace Datapath: Add ALG infra and FTP.") Signed-off-by: Darrell Ball --- lib/conntrack.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/conntrack.c b/lib/conntrack.c index 6691877..08bec61 100644 --- a/lib/conntrack.c +++ b/lib/conntrack.c @@ -1135,8 +1135,11 @@ process_one(struct conntrack *ct, struct dp_packet *pkt, } else { create_new_conn = conn_update_state(ct, pkt, ctx, &conn, now, bucket); - handle_ftp_ctl(ct, ctx, pkt, conn, now, CT_FTP_CTL_OTHER, - !!nat_action_info); + + if (!create_new_conn) { + handle_ftp_ctl(ct, ctx, pkt, conn, now, CT_FTP_CTL_OTHER, + !!nat_action_info); + } } } else { create_new_conn = conn_update_state(ct, pkt, ctx, &conn, now,