Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 348405
b: refs/heads/master
c: 2727de7
h: refs/heads/master
i:
  348403: ed9ce59
v: v3
  • Loading branch information
Eric Dumazet authored and Pablo Neira Ayuso committed Jan 4, 2013
1 parent 2c875fc commit 62b1245
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 757ae316fb35811cfd8c67de0e0b8680ec4c1f37
refs/heads/master: 2727de76041b2064c0b74f00a2a89678fb3efafc
23 changes: 18 additions & 5 deletions trunk/net/netfilter/xt_recent.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <linux/skbuff.h>
#include <linux/inet.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <net/net_namespace.h>
#include <net/netns/generic.h>

Expand Down Expand Up @@ -310,6 +311,14 @@ recent_mt(const struct sk_buff *skb, struct xt_action_param *par)
return ret;
}

static void recent_table_free(void *addr)
{
if (is_vmalloc_addr(addr))
vfree(addr);
else
kfree(addr);
}

static int recent_mt_check(const struct xt_mtchk_param *par,
const struct xt_recent_mtinfo_v1 *info)
{
Expand All @@ -322,6 +331,7 @@ static int recent_mt_check(const struct xt_mtchk_param *par,
#endif
unsigned int i;
int ret = -EINVAL;
size_t sz;

if (unlikely(!hash_rnd_inited)) {
get_random_bytes(&hash_rnd, sizeof(hash_rnd));
Expand Down Expand Up @@ -360,8 +370,11 @@ static int recent_mt_check(const struct xt_mtchk_param *par,
goto out;
}

t = kzalloc(sizeof(*t) + sizeof(t->iphash[0]) * ip_list_hash_size,
GFP_KERNEL);
sz = sizeof(*t) + sizeof(t->iphash[0]) * ip_list_hash_size;
if (sz <= PAGE_SIZE)
t = kzalloc(sz, GFP_KERNEL);
else
t = vzalloc(sz);
if (t == NULL) {
ret = -ENOMEM;
goto out;
Expand All @@ -377,14 +390,14 @@ static int recent_mt_check(const struct xt_mtchk_param *par,
uid = make_kuid(&init_user_ns, ip_list_uid);
gid = make_kgid(&init_user_ns, ip_list_gid);
if (!uid_valid(uid) || !gid_valid(gid)) {
kfree(t);
recent_table_free(t);
ret = -EINVAL;
goto out;
}
pde = proc_create_data(t->name, ip_list_perms, recent_net->xt_recent,
&recent_mt_fops, t);
if (pde == NULL) {
kfree(t);
recent_table_free(t);
ret = -ENOMEM;
goto out;
}
Expand Down Expand Up @@ -435,7 +448,7 @@ static void recent_mt_destroy(const struct xt_mtdtor_param *par)
remove_proc_entry(t->name, recent_net->xt_recent);
#endif
recent_table_flush(t);
kfree(t);
recent_table_free(t);
}
mutex_unlock(&recent_mutex);
}
Expand Down

0 comments on commit 62b1245

Please sign in to comment.