30 Commits

Author SHA1 Message Date
Jan Engelhardt
c839e87bbb xt_geoip: check for allocation overflow 2017-06-26 22:03:53 +02:00
Jan Engelhardt
d48a5fe0f4 xt_geoip: do not throw a warnings when country database is size 0 2013-05-30 17:00:25 +02:00
Changli Gao
a5355e74ea xt_geoip: avoid recursive function calls
The stack memory is very limited in Linux kernel.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
2011-04-14 09:07:25 +02:00
Jan Engelhardt
7a8bfed52c xt_geoip: keep compiling for <= 2.6.23 2011-02-02 05:21:56 +01:00
Jan Engelhardt
07cd29d9ce xt_geoip: IPv6 support 2011-02-02 04:47:28 +01:00
Jan Engelhardt
eb9634aee6 xt_geoip: v4/v6 name preparations 2011-02-02 04:43:36 +01:00
Jan Engelhardt
19f241a09c xt_geoip: cleanups, preparations for IPv6 geoip 2011-02-02 01:55:09 +01:00
Jan Engelhardt
4dcefe4b95 xt_geoip: fix possible out-of-bounds access
It is possible for geoip_bsearch() to pick mid == sizeof(subnets).

Consider a set with a single entry and a "address to test"
higher than the range:

1st call: lo = 0, hi = 1 -> mid will be 0
2nd call: lo = 1, hi = 1 -> mid will be 1

On the 2nd call, we'll examine random data.

Reported-by: Florian Westphal <fw@strlen.de>
2010-06-13 10:40:07 +02:00
Jan Engelhardt
9a18a05d02 compat_xtables: move to 2.6.35 xt_action_param (2/3) 2010-05-13 19:45:52 +02:00
Jan Engelhardt
5b472be9bb compat_xtables: move to 2.6.35 xt_action_param (1/3) 2010-05-13 19:28:37 +02:00
Jan Engelhardt
beb3358297 compat_xtables: move to 2.6.35 API for matches 2010-04-05 00:43:47 +02:00
Jan Engelhardt
137ecb9814 extensions: bump revision number to avoid possible POM clash
Users still using a kernel with POM modules may have problems due to
differing binary structures. Bump the revision numbers of the
Xtables-addons modules, to make them distinct from POM.
2009-05-14 21:42:05 +02:00
Jan Engelhardt
ee7e4f5a42 Update for Linux 2.6.28 2008-11-18 12:51:25 +01:00
Jan Engelhardt
be6fbee56a src: use NFPROTO_ constants 2008-11-18 11:57:14 +01:00
Jan Engelhardt
f4c4208e75 geoip: use appropriate and normal types
For the header file, we need __u32 and so on because they are exported
to userspace and rather constitute a kernel header.

Use normal types instead of uintXX_t in the main code.
2008-03-22 03:59:57 +01:00
Jan Engelhardt
52a0ed7f15 geoip: use rcu to reduce time spinlocks are held
spin_lock_bh does not look safe (only disables preempt on current
CPU?). Change to spin_lock, that also avoids the management overhead
of spin_lock_bh. to spin_lock to avoid management overhead.

Use rcu in match and destroy function.
2008-03-22 03:59:57 +01:00
Jan Engelhardt
000d813171 geoip: use real atomic_t and remove casts from uint32_t 2008-03-22 03:59:57 +01:00
Jan Engelhardt
e45cb21ad6 geoip: use struct list_head instead of self-cooked list 2008-03-22 03:59:57 +01:00
Jan Engelhardt
7aae90da5a geoip: use local-portable aligned_u64 pointer values
A 64-bit kernel will interpret the pointer with 64 bits width, while
a 32-bit userspace filled in only 32 of it, leaving the other 32
undefined. This must be avoided.
2008-03-22 03:59:56 +01:00
Jan Engelhardt
fd5321c7d8 geoip: split user/kernel-visible parts of struct geoip_info 2008-03-22 03:59:56 +01:00
Jan Engelhardt
65eeb7f1f6 geoip: use vmalloc due to potential list size
The subnet list may become really large (United States: ~15000
entries), which means a use of roughly 120 KB, and kmalloc may fail
to find a contiguous block in physical memory. Virtual contiguity is
enough, so use vmalloc/vfree.

vfree may not be called within a spin_lock_bh area, so release the
lock first, it is safe to do so.
2008-03-22 03:59:55 +01:00
Jan Engelhardt
848484c08c geoip: use a binary search to replace the current linear one
Certain countries have lots (around 10000) of IP address ranges
(US,GB,DE,...). The current linear search is really bad:

No firewall:
3000 packets transmitted, 3000 received, 0% packet loss, time 1992ms

Testing against the countries with top 50 IP ranges:
3000 packets transmitted, 3000 received, 0% packet loss, time 8998ms

With binary search:
3000 packets transmitted, 3000 received, 0% packet loss, time 2358ms
2008-03-22 03:59:45 +01:00
Jan Engelhardt
8c58a61f52 geoip: address comparison is inclusive
subnet is somewhat a wrong term, geoip actually uses ipranges. Either
way, the comparison needs to be >= and <= instead of > <.
2008-03-22 03:59:45 +01:00
Jan Engelhardt
93c7d0ac47 geoip: lock timing correctness
find_node: The reference count needs to be increased while the lock
is held. Otherwise, the node may disappear right after the lock was
released and increase was attempted, leading to an oops.

remove_node: The reference count needs to be checked while the lock
is held. Otherwise, the node may be used in the match function or
returned from find_node while it has a zero refcount.
2008-03-22 03:59:45 +01:00
Jan Engelhardt
df063ab61c geoip: add missing kfree in error path 2008-03-22 03:59:44 +01:00
Jan Engelhardt
d480ea2b1f geoip: sort #include list 2008-03-22 03:59:44 +01:00
Jan Engelhardt
205a006ac9 geoip: use tabs not spaces and indent 2008-03-22 03:59:44 +01:00
Jan Engelhardt
9f45aa737a geoip: remove redundant casts 2008-03-22 03:59:44 +01:00
Jan Engelhardt
f1615a03f3 geoip: remove unused code and unneeded per-info refcount
- freeing userspace memory is not the kernel's job, really.
- checkentry is called exactly once, as is destroy.
2008-03-22 03:59:44 +01:00
Jan Engelhardt
3554e348bc geoip: import 20080214 code base 2008-03-22 03:59:42 +01:00