If a rule using ipt_recent is created with a hit count greater than
ip_pkt_list_tot, the rule will never match as it cannot keep track
of enough timestamps. This patch makes ipt_recent refuse to create such
rules.
With ip_pkt_list_tot's default value of 20, the following can be used
to reproduce the problem.
nc -u -l 0.0.0.0 1234 &
for i in `seq 1 100`; do echo $i | nc -w 1 -u 127.0.0.1 1234; done
This limits it to 20 packets:
iptables -A OUTPUT -p udp --dport 1234 -m recent --set --name test \
--rsource
iptables -A OUTPUT -p udp --dport 1234 -m recent --update --seconds \
60 --hitcount 20 --name test --rsource -j DROP
While this is unlimited:
iptables -A OUTPUT -p udp --dport 1234 -m recent --set --name test \
--rsource
iptables -A OUTPUT -p udp --dport 1234 -m recent --update --seconds \
60 --hitcount 21 --name test --rsource -j DROP
With the patch the second rule-set will throw an EINVAL.
Signed-off-by: Daniel Hokka Zakrisson <daniel@hozac.com>
Reported-by: Sean Kennedy <skennedy@vcn.com>
---
net/ipv4/netfilter/ipt_recent.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/ipv4/netfilter/ipt_recent.c
b/net/ipv4/netfilter/ipt_recent.c
index 68cbe3c..8e8f042 100644
--- a/net/ipv4/netfilter/ipt_recent.c
+++ b/net/ipv4/netfilter/ipt_recent.c
@@ -252,6 +252,8 @@ recent_mt_check(const char *tablename, const void *ip,
if ((info->check_set & (IPT_RECENT_SET | IPT_RECENT_REMOVE)) &&
(info->seconds || info->hit_count))
return false;
+ if (info->hit_count > ip_pkt_list_tot)
+ return false;
if (info->name[0] == '\0' ||
strnlen(info->name, IPT_RECENT_NAME_LEN) == IPT_RECENT_NAME_LEN)
return false;
--
1.5.3.3
--
| Andrew Morton | Re: [PATCH 00/23] per device dirty throttling -v8 |
| Mariusz Kozlowski | [PATCH 02] kmalloc + memset conversion to kzalloc |
| Andi Kleen | [PATCH x86] [3/16] Turn irq debugging options into module params |
| Shawn Bohrer | Re: x86: 4kstacks default |
git: | |
| Sean | Re: VCS comparison table |
| Eric Wong | Re: [RFC] Git config file reader in Perl (WIP) |
| free cycle | How to Import a bitkeeper repo into git |
| Petko Manolov | git and binary files |
| Alex Thurlow | Router performance on OpenBSD and OpenBGPD |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
| frantisek holop | nptd regression in 4.2 |
| Richard Stallman | Real men don't attack straw men |
| Matthew Dharm | Re: [RFC] Patch to option HSO driver to the kernel |
| David Miller | Re: 2.6.25-rc8: FTP transfer errors |
| Indan Zupancic | Re: Realtek 8111C transmit timed out |
| Julius Volz | [PATCH RFC 02/24] IPVS: Add genetlink interface implementation |
