From patchwork Tue Dec 6 15:04:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Conole X-Patchwork-Id: 703195 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3tY4hL0878z9vmC for ; Wed, 7 Dec 2016 02:06:10 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bytheb-org.20150623.gappssmtp.com header.i=@bytheb-org.20150623.gappssmtp.com header.b="RlE4l2zO"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752087AbcLFPFu (ORCPT ); Tue, 6 Dec 2016 10:05:50 -0500 Received: from mail-qk0-f196.google.com ([209.85.220.196]:34981 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751556AbcLFPFt (ORCPT ); Tue, 6 Dec 2016 10:05:49 -0500 Received: by mail-qk0-f196.google.com with SMTP id n204so44031676qke.2 for ; Tue, 06 Dec 2016 07:05:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytheb-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:user-agent:mime-version; bh=DtfAOxdnsBi5RtkE9EX08N6l5wgFE9Nl0OpCUhUjxrg=; b=RlE4l2zOhqv70lCXpUzD58toFIiLI4QvhEOG4siHVJ0xPvMvTrxKsV3NNLT5CBaLL/ C6f2KbW9wdRPaY1PjlNMdUi+n+abK4z5U5UQWpkCwfv8zBoyvW80tDbptWf4FZ1bOepj PrOz1H1Hq9M7BgeOMVf2PgjnGWs1gr66d/9n2U50eQT+9bPvh7NxMHbR8ApEmwcJRwgE OQCTLV8SIbNCCitaVx2Un8gRdxFFUWy79rAP2+eqnLvKcDPeH3BK2CkhuevcCYgOVbx6 m+tPldhNCZ0jV3rYXyT/W4PUuV2woJapRUvuJFGcA4PPT3J7/9AHUCawyGZh5FFaps0k S7Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:user-agent :mime-version; bh=DtfAOxdnsBi5RtkE9EX08N6l5wgFE9Nl0OpCUhUjxrg=; b=j/IVHVSmG9OzZEt68SHJrf8vgce9e4PRRogFjhdDkp4lETxE9f3cSaZxIVdFH2f7oR moBM99z7tDXdg2lrjNF5rIS7dmddHgdY6+EPDGqkf6XYypnVJatXhNNZg9/sQMUH0mrM bENsKP5BlOSJAKJrpWn4RwO0C+cpxagZrsjGA/T3LLl6njAikZEKCLxHVkYeUBllvDdV uoGI3EzNid0MwiLdwbP4mfIUws7Sgt5mbFUHNg5hCKqRCYKNkKxVBv58FTEVJqZxOCvv b/6Qj7C8kdgL8HEVZV3WU1f2UruLtVEKmQ5mzqlSulXGNQwsHPaQ8cd81f42xBlBvsqc 7l5g== X-Gm-Message-State: AKaTC02j9csIlm/kZ/MTJLa+GURyw1Up0DefWImMh/3mRhJ1UzHmxLEaVppL7ZikpKEiNg== X-Received: by 10.55.170.131 with SMTP id t125mr54532309qke.15.1481036700824; Tue, 06 Dec 2016 07:05:00 -0800 (PST) Received: from dhcp-25-97.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id o31sm12204317qtf.20.2016.12.06.07.04.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Dec 2016 07:04:59 -0800 (PST) From: Aaron Conole To: netfilter-devel@vger.kernel.org Cc: dan.carpenter@oracle.com Subject: [PATCH nf-next] netfilter: add list element test to br_netfilter_hooks Date: Tue, 06 Dec 2016 10:04:58 -0500 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org The for-loop in the bridge hook entries assumes that the elements are always present. However, this assumption may not always be true. Fixes: 66cfc1dd07c7 ("netfilter: convert while loops to for loops") Signed-off-by: Aaron Conole --- Pablo, if possible could this be squashed into the commit instead? I only did a build test of this, but it should be correct. -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hooks.c index fbe35b4..b12501a 100644 --- a/net/bridge/br_netfilter_hooks.c +++ b/net/bridge/br_netfilter_hooks.c @@ -1009,7 +1009,7 @@ int br_nf_hook_thresh(unsigned int hook, struct net *net, int ret; for (elem = rcu_dereference(net->nf.hooks[NFPROTO_BRIDGE][hook]); - nf_hook_entry_priority(elem) <= NF_BR_PRI_BRNF; + elem && nf_hook_entry_priority(elem) <= NF_BR_PRI_BRNF; elem = rcu_dereference(elem->next)) ;