All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vitaly E. Lavrov" <lve@guap.ru>
To: netfilter-devel@vger.kernel.org
Subject: xt_recent BUG() in kernel 3.2/3.4  & patch
Date: Sun, 09 Dec 2012 15:16:29 +0400	[thread overview]
Message-ID: <50C4730D.2080401@guap.ru> (raw)

Appears when stopping container without emptying tables (iptables 
-F/iptables -t mangle -F)

Problem: recent_mt_destroy called after __net_exit recent_net_exit() !

xt_hashlimit contains a BUG () and should be corrected similarly

Possible patch for xt_recent is below
=============
diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
index d2ff15a..0fc5c32 100644
--- a/net/netfilter/xt_recent.c
+++ b/net/netfilter/xt_recent.c
@@ -75,6 +75,9 @@ struct recent_entry {
  struct recent_table {
         struct list_head        list;
         char                    name[XT_RECENT_NAME_LEN];
+#ifdef CONFIG_PROC_FS
+       struct proc_dir_entry   *pe;
+#endif
         unsigned int            refcnt;
         unsigned int            entries;
         struct list_head        lru_list;
@@ -375,6 +378,7 @@ static int recent_mt_check(const struct 
xt_mtchk_param *par)
         }
         pde->uid = ip_list_uid;
         pde->gid = ip_list_gid;
+       t->pe = pde;
  #endif
         spin_lock_bh(&recent_lock);
         list_add_tail(&t->list, &recent_net->tables);
@@ -398,7 +402,8 @@ static void recent_mt_destroy(const struct 
xt_mtdtor_param *par)
                 list_del(&t->list);
                 spin_unlock_bh(&recent_lock);
  #ifdef CONFIG_PROC_FS
-               remove_proc_entry(t->name, recent_net->xt_recent);
+               if(t->pe)
+                       remove_proc_entry(t->name, recent_net->xt_recent);
  #endif
                 recent_table_flush(t);
                 kfree(t);
@@ -607,7 +612,19 @@ static void __net_exit recent_net_exit(struct net *net)
  {
         struct recent_net *recent_net = recent_pernet(net);

-       BUG_ON(!list_empty(&recent_net->tables));
+       if(!list_empty(&recent_net->tables)) {
+#ifdef CONFIG_PROC_FS
+               struct recent_table *t;
+               spin_lock_bh(&recent_lock);
+               list_for_each_entry(t, &recent_net->tables, list) {
+                       t->pe = NULL;
+                       remove_proc_entry(t->name, recent_net->xt_recent);
+               }
+               spin_unlock_bh(&recent_lock);
+#endif
+               printk(KERN_INFO "%s net %x: Warning! Tables not empty!\n",
+                               __func__,(u32)net);
+       }
         recent_proc_net_exit(net);
  }
==================

             reply	other threads:[~2012-12-09 11:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-09 11:16 Vitaly E. Lavrov [this message]
2012-12-11  1:20 ` xt_recent BUG() in kernel 3.2/3.4 & patch Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50C4730D.2080401@guap.ru \
    --to=lve@guap.ru \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.