Re: [stable] regression in iptables: recent filter

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Alexey Dobriyan
Date: Thursday, September 11, 2008 - 8:10 pm

On Fri, Sep 12, 2008 at 11:53:35AM +1000, Grant Coady wrote:

You were einvaled by the following commit:

Reloading module with ip_pkt_list_tot=60 should fix it.

commit d0ebf133590abdc035af6e19a6568667af0ab3b0
Author: Daniel Hokka Zakrisson <daniel@hozac.com>
Date:   Thu Mar 20 15:07:10 2008 -0700

    [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>
    Signed-off-by: David S. Miller <davem@davemloft.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;
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[stable] regression in iptables: recent filter, Grant Coady, (Thu Sep 11, 6:53 pm)
Re: [stable] regression in iptables: recent filter, Andrew Morton, (Thu Sep 11, 8:01 pm)
Re: [stable] regression in iptables: recent filter, David Miller, (Thu Sep 11, 8:04 pm)
Re: [stable] regression in iptables: recent filter, Alexey Dobriyan, (Thu Sep 11, 8:10 pm)
Re: [stable] regression in iptables: recent filter, Alexey Dobriyan, (Thu Sep 11, 8:11 pm)
Re: [stable] regression in iptables: recent filter, Grant Coady, (Thu Sep 11, 8:29 pm)
Re: [stable] regression in iptables: recent filter, Jan Engelhardt, (Thu Sep 11, 10:46 pm)