Received: by 10.223.176.5 with SMTP id f5csp3440865wra; Mon, 29 Jan 2018 13:13:05 -0800 (PST) X-Google-Smtp-Source: AH8x226bAR72wwO98Eanbp1V5BEXOInJNWtc4iDa+fSsJxA18gbXrxh9EH+o78kmJqvPXCCN7Gop X-Received: by 2002:a17:902:d81:: with SMTP id 1-v6mr23638852plv.270.1517260385357; Mon, 29 Jan 2018 13:13:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517260385; cv=none; d=google.com; s=arc-20160816; b=dIC9WXj5qGiQUZoWEki6HzVN4Toq4LZXj4ohSZfhb8JYK3edBQh36LTFKGwn1oC1SI jVW8+hdV5CpbFGvpEiDgW92SQHyNXFzKF2vi+je5vXehDiWyamWqCpBhEC/aAfU66BXA T/npULg8KpaVOMPxHcpQ6i5jT2NJ6x4qMU9gJ+cjQWSCIdKv+8w1C663q26IdhAZ5WGx t8ICt9eWWsVRPJog+Hwpy5+CciEfzrg0Jf9raHWI8JYOBs6/DDZV1YKUWmruiVEE5Y3q bjOG/iXI1lYrc9UtpYbnfKLg7J416Xcoga7+zvNb6UWNU9P46kliIuRpMEjM3O9IKgYK s5ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=otCFLgMLDLNbwqIfI/EFrC0aBoPRk9y18gk7pOiall4=; b=USlzSoWj4cI6zXcOL9GP+o2qNkfENvEXxUzonB2y33cJBakfzX6j7mfzrhUggQXvAW Q/ELfMCVyOiCHvFVH1c48wVTNBUKjPNCz6V2lzcHBviwYRpJ+k0MqGBztpk9MQq2vlYy u0dlkyZ2oAUltB6G6yzTDhd2FtOiCPD4DXOGdIPdjibYSmnDpFZGTdDvtmMC5yH6pYLR NSXLj3FotgR02fenZFUdqWiDh5Fu778NWNjTMm7H1vOhZS+gMp9IAHSF7tCT9OoSAj/C hoJVxCqkuc6BjICyaFUsi9y4ayNc/TzIo25sUoxw2X7U7wWWhqOuI5eCaN8vOSO9n1AB VtUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i7si634636pgr.255.2018.01.29.13.12.50; Mon, 29 Jan 2018 13:13:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751645AbeA2VMS (ORCPT + 99 others); Mon, 29 Jan 2018 16:12:18 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:44684 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752516AbeA2UFM (ORCPT ); Mon, 29 Jan 2018 15:05:12 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 347BF2E9E; Mon, 29 Jan 2018 12:58:52 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Florian Westphal , Pablo Neira Ayuso , Michal Kubecek Subject: [PATCH 3.18 28/52] netfilter: restart search if moved to other chain Date: Mon, 29 Jan 2018 13:56:46 +0100 Message-Id: <20180129123629.430826236@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123628.168904217@linuxfoundation.org> References: <20180129123628.168904217@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Florian Westphal commit 95a8d19f28e6b29377a880c6264391a62e07fccc upstream. In case nf_conntrack_tuple_taken did not find a conflicting entry check that all entries in this hash slot were tested and restart in case an entry was moved to another chain. Reported-by: Eric Dumazet Fixes: ea781f197d6a ("netfilter: nf_conntrack: use SLAB_DESTROY_BY_RCU and get rid of call_rcu()") Signed-off-by: Florian Westphal Acked-by: Eric Dumazet Signed-off-by: Pablo Neira Ayuso Acked-by: Michal Kubecek Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_conntrack_core.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -695,6 +695,7 @@ nf_conntrack_tuple_taken(const struct nf * least once for the stats anyway. */ rcu_read_lock_bh(); + begin: hlist_nulls_for_each_entry_rcu(h, n, &net->ct.hash[hash], hnnode) { ct = nf_ct_tuplehash_to_ctrack(h); if (ct != ignored_conntrack && @@ -706,6 +707,12 @@ nf_conntrack_tuple_taken(const struct nf } NF_CT_STAT_INC(net, searched); } + + if (get_nulls_value(n) != hash) { + NF_CT_STAT_INC(net, search_restart); + goto begin; + } + rcu_read_unlock_bh(); return 0;