Skip to content

Commit

Permalink
netfilter: fix two recent sysctl problems
Browse files Browse the repository at this point in the history
Starting with 9043476 ("[PATCH]
sanitize proc_sysctl") we have two netfilter releated problems:

 - WARNING: at kernel/sysctl.c:1966 unregister_sysctl_table+0xcc/0x103(),
   caused by wrong order of ini/fini calls

 - net.netfilter is duplicated and has truncated set of records

Thanks to very useful guidelines from Al Viro, this patch fixes both
of them.

Signed-off-by: Krzysztof Piotr Oledzki <ole@ans.pl>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Krzysztof Piotr Oledzki authored and David S. Miller committed Aug 6, 2008
1 parent 1ca615f commit 9714be7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
6 changes: 3 additions & 3 deletions net/netfilter/nf_conntrack_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1032,10 +1032,10 @@ void nf_conntrack_cleanup(void)
nf_ct_free_hashtable(nf_conntrack_hash, nf_conntrack_vmalloc,
nf_conntrack_htable_size);

nf_conntrack_proto_fini();
nf_conntrack_helper_fini();
nf_conntrack_expect_fini();
nf_conntrack_acct_fini();
nf_conntrack_expect_fini();
nf_conntrack_helper_fini();
nf_conntrack_proto_fini();
}

struct hlist_head *nf_ct_alloc_hashtable(unsigned int *sizep, int *vmalloced)
Expand Down
28 changes: 17 additions & 11 deletions net/netfilter/nf_conntrack_standalone.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ static int log_invalid_proto_min = 0;
static int log_invalid_proto_max = 255;

static struct ctl_table_header *nf_ct_sysctl_header;
static struct ctl_table_header *nf_ct_netfilter_header;

static ctl_table nf_ct_sysctl_table[] = {
{
Expand Down Expand Up @@ -383,12 +384,6 @@ static ctl_table nf_ct_sysctl_table[] = {
#define NET_NF_CONNTRACK_MAX 2089

static ctl_table nf_ct_netfilter_table[] = {
{
.ctl_name = NET_NETFILTER,
.procname = "netfilter",
.mode = 0555,
.child = nf_ct_sysctl_table,
},
{
.ctl_name = NET_NF_CONNTRACK_MAX,
.procname = "nf_conntrack_max",
Expand All @@ -409,18 +404,29 @@ EXPORT_SYMBOL_GPL(nf_ct_log_invalid);

static int nf_conntrack_standalone_init_sysctl(void)
{
nf_ct_sysctl_header =
nf_ct_netfilter_header =
register_sysctl_paths(nf_ct_path, nf_ct_netfilter_table);
if (nf_ct_sysctl_header == NULL) {
printk("nf_conntrack: can't register to sysctl.\n");
return -ENOMEM;
}
if (!nf_ct_netfilter_header)
goto out;

nf_ct_sysctl_header =
register_sysctl_paths(nf_net_netfilter_sysctl_path,
nf_ct_sysctl_table);
if (!nf_ct_sysctl_header)
goto out_unregister_netfilter;

return 0;

out_unregister_netfilter:
unregister_sysctl_table(nf_ct_netfilter_header);
out:
printk("nf_conntrack: can't register to sysctl.\n");
return -ENOMEM;
}

static void nf_conntrack_standalone_fini_sysctl(void)
{
unregister_sysctl_table(nf_ct_netfilter_header);
unregister_sysctl_table(nf_ct_sysctl_header);
}
#else
Expand Down

0 comments on commit 9714be7

Please sign in to comment.