{"id":809448,"url":"http://patchwork.ozlabs.org/api/1.2/patches/809448/?format=json","web_url":"http://patchwork.ozlabs.org/project/netfilter-devel/patch/1504478574-13281-7-git-send-email-pablo@netfilter.org/","project":{"id":26,"url":"http://patchwork.ozlabs.org/api/1.2/projects/26/?format=json","name":"Netfilter Development","link_name":"netfilter-devel","list_id":"netfilter-devel.vger.kernel.org","list_email":"netfilter-devel@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1504478574-13281-7-git-send-email-pablo@netfilter.org>","list_archive_url":null,"date":"2017-09-03T22:42:49","name":"[42/47] netfilter: debug: check for sorted array","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"1cfa1e8fa6593ed8589b9b1e4557c5dadf83667d","submitter":{"id":1315,"url":"http://patchwork.ozlabs.org/api/1.2/people/1315/?format=json","name":"Pablo Neira Ayuso","email":"pablo@netfilter.org"},"delegate":{"id":6139,"url":"http://patchwork.ozlabs.org/api/1.2/users/6139/?format=json","username":"pablo","first_name":"Pablo","last_name":"Neira","email":"pablo@netfilter.org"},"mbox":"http://patchwork.ozlabs.org/project/netfilter-devel/patch/1504478574-13281-7-git-send-email-pablo@netfilter.org/mbox/","series":[{"id":1282,"url":"http://patchwork.ozlabs.org/api/1.2/series/1282/?format=json","web_url":"http://patchwork.ozlabs.org/project/netfilter-devel/list/?series=1282","date":"2017-09-03T22:40:11","name":null,"version":1,"mbox":"http://patchwork.ozlabs.org/series/1282/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/809448/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/809448/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netfilter-devel-owner@vger.kernel.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netfilter-devel-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xlp1G4GMsz9s06\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon,  4 Sep 2017 08:43:46 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1753503AbdICWnk (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tSun, 3 Sep 2017 18:43:40 -0400","from mail.us.es ([193.147.175.20]:53060 \"EHLO mail.us.es\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1753501AbdICWnM (ORCPT <rfc822; netfilter-devel@vger.kernel.org>);\n\tSun, 3 Sep 2017 18:43:12 -0400","from antivirus1-rhel7.int (unknown [192.168.2.11])\n\tby mail.us.es (Postfix) with ESMTP id 5ACDB190F67\n\tfor <netfilter-devel@vger.kernel.org>;\n\tMon,  4 Sep 2017 00:42:46 +0200 (CEST)","from antivirus1-rhel7.int (localhost [127.0.0.1])\n\tby antivirus1-rhel7.int (Postfix) with ESMTP id 4BFCADA56C\n\tfor <netfilter-devel@vger.kernel.org>;\n\tMon,  4 Sep 2017 00:42:46 +0200 (CEST)","by antivirus1-rhel7.int (Postfix, from userid 99)\n\tid 41B15B502E; Mon,  4 Sep 2017 00:42:46 +0200 (CEST)","from antivirus1-rhel7.int (localhost [127.0.0.1])\n\tby antivirus1-rhel7.int (Postfix) with ESMTP id 2F069B5026;\n\tMon,  4 Sep 2017 00:42:44 +0200 (CEST)","from 192.168.1.97 (192.168.1.97) by antivirus1-rhel7.int\n\t(F-Secure/fsigk_smtp/550/antivirus1-rhel7.int); \n\tMon, 04 Sep 2017 00:42:44 +0200 (CEST)","from salvia.here (unknown [31.4.193.113])\n\t(Authenticated sender: pneira@us.es)\n\tby entrada.int (Postfix) with ESMTPA id D26864265A20;\n\tMon,  4 Sep 2017 00:42:43 +0200 (CEST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.1 (2015-04-28) on\n\tantivirus1-rhel7.int","X-Spam-Level":"","X-Spam-Status":"No, score=-108.2 required=7.5 tests=ALL_TRUSTED,BAYES_50,\n\tSMTPAUTH_US2,USER_IN_WHITELIST autolearn=disabled version=3.4.1","X-Virus-Status":"clean(F-Secure/fsigk_smtp/550/antivirus1-rhel7.int)","X-SMTPAUTHUS":"auth mail.us.es","From":"Pablo Neira Ayuso <pablo@netfilter.org>","To":"netfilter-devel@vger.kernel.org","Cc":"davem@davemloft.net, netdev@vger.kernel.org","Subject":"[PATCH 42/47] netfilter: debug: check for sorted array","Date":"Mon,  4 Sep 2017 00:42:49 +0200","Message-Id":"<1504478574-13281-7-git-send-email-pablo@netfilter.org>","X-Mailer":"git-send-email 2.1.4","In-Reply-To":"<1504478574-13281-1-git-send-email-pablo@netfilter.org>","References":"<1504478574-13281-1-git-send-email-pablo@netfilter.org>","X-Virus-Scanned":"ClamAV using ClamSMTP","Sender":"netfilter-devel-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netfilter-devel.vger.kernel.org>","X-Mailing-List":"netfilter-devel@vger.kernel.org"},"content":"From: Florian Westphal <fw@strlen.de>\n\nMake sure our grow/shrink routine places them in the correct order.\n\nSigned-off-by: Florian Westphal <fw@strlen.de>\nSigned-off-by: Pablo Neira Ayuso <pablo@netfilter.org>\n---\n net/netfilter/core.c | 23 +++++++++++++++++++++++\n 1 file changed, 23 insertions(+)","diff":"diff --git a/net/netfilter/core.c b/net/netfilter/core.c\nindex 1a9e23c9ab98..164ad20d0bd2 100644\n--- a/net/netfilter/core.c\n+++ b/net/netfilter/core.c\n@@ -157,6 +157,27 @@ nf_hook_entries_grow(const struct nf_hook_entries *old,\n \treturn new;\n }\n \n+static void hooks_validate(const struct nf_hook_entries *hooks)\n+{\n+#ifdef CONFIG_DEBUG_KERNEL\n+\tstruct nf_hook_ops **orig_ops;\n+\tint prio = INT_MIN;\n+\tsize_t i = 0;\n+\n+\torig_ops = nf_hook_entries_get_hook_ops(hooks);\n+\n+\tfor (i = 0; i < hooks->num_hook_entries; i++) {\n+\t\tif (orig_ops[i] == &dummy_ops)\n+\t\t\tcontinue;\n+\n+\t\tWARN_ON(orig_ops[i]->priority < prio);\n+\n+\t\tif (orig_ops[i]->priority > prio)\n+\t\t\tprio = orig_ops[i]->priority;\n+\t}\n+#endif\n+}\n+\n /*\n  * __nf_hook_entries_try_shrink - try to shrink hook array\n  *\n@@ -210,6 +231,7 @@ static void *__nf_hook_entries_try_shrink(struct nf_hook_entries __rcu **pp)\n \t\tnew_ops[j] = (void *)orig_ops[i];\n \t\tj++;\n \t}\n+\thooks_validate(new);\n out_assign:\n \trcu_assign_pointer(*pp, new);\n \treturn old;\n@@ -261,6 +283,7 @@ int nf_register_net_hook(struct net *net, const struct nf_hook_ops *reg)\n \tif (IS_ERR(new_hooks))\n \t\treturn PTR_ERR(new_hooks);\n \n+\thooks_validate(new_hooks);\n #ifdef CONFIG_NETFILTER_INGRESS\n \tif (reg->pf == NFPROTO_NETDEV && reg->hooknum == NF_NETDEV_INGRESS)\n \t\tnet_inc_ingress_queue();\n","prefixes":["42/47"]}