* [NETFILTER 02/02]: ipt_recent: sanity check hit count
@ 2008-03-20 17:55 Patrick McHardy
2008-03-20 22:07 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Patrick McHardy @ 2008-03-20 17:55 UTC (permalink / raw)
To: David S. Miller; +Cc: Netfilter Development Mailinglist
[-- Attachment #1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2: 02.diff --]
[-- Type: text/x-diff, Size: 1968 bytes --]
commit be32bceccbf7051ff1433943df7e808c576d1191
Author: Daniel Hokka Zakrisson <daniel@hozac.com>
Date: Thu Mar 20 18:34:39 2008 +0100
[NETFILTER]: ipt_recent: sanity check hit count
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.
Reported-by: Sean Kennedy <skennedy@vcn.com>
Signed-off-by: Daniel Hokka Zakrisson <daniel@hozac.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
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;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [NETFILTER 02/02]: ipt_recent: sanity check hit count
2008-03-20 17:55 [NETFILTER 02/02]: ipt_recent: sanity check hit count Patrick McHardy
@ 2008-03-20 22:07 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2008-03-20 22:07 UTC (permalink / raw)
To: kaber; +Cc: netfilter-devel
From: Patrick McHardy <kaber@trash.net>
Date: Thu, 20 Mar 2008 18:55:19 +0100
> [NETFILTER]: ipt_recent: sanity check hit count
>
> 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.
>
> Reported-by: Sean Kennedy <skennedy@vcn.com>
> Signed-off-by: Daniel Hokka Zakrisson <daniel@hozac.com>
> Signed-off-by: Patrick McHardy <kaber@trash.net>
Also applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-03-20 22:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-20 17:55 [NETFILTER 02/02]: ipt_recent: sanity check hit count Patrick McHardy
2008-03-20 22:07 ` David Miller
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.