netfilter 02/08: xt_recent: fix buffer overflow

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Patrick McHardy
Date: Wednesday, February 24, 2010 - 10:49 am

commit 2c08522e5d2f0af2d6f05be558946dcbf8173683
Author: Tim Gardner <tim.gardner@canonical.com>
Date:   Tue Feb 23 14:55:21 2010 +0100

    netfilter: xt_recent: fix buffer overflow
    
    e->index overflows e->stamps[] every ip_pkt_list_tot packets.
    
    Consider the case when ip_pkt_list_tot==1; the first packet received is stored
    in e->stamps[0] and e->index is initialized to 1. The next received packet
    timestamp is then stored at e->stamps[1] in recent_entry_update(),
    a buffer overflow because the maximum e->stamps[] index is 0.
    
    Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
    Cc: stable@kernel.org
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
index 132cfaa..1278f0a 100644
--- a/net/netfilter/xt_recent.c
+++ b/net/netfilter/xt_recent.c
@@ -177,10 +177,10 @@ recent_entry_init(struct recent_table *t, const union nf_inet_addr *addr,
 
 static void recent_entry_update(struct recent_table *t, struct recent_entry *e)
 {
+	e->index %= ip_pkt_list_tot;
 	e->stamps[e->index++] = jiffies;
 	if (e->index > e->nstamps)
 		e->nstamps = e->index;
-	e->index %= ip_pkt_list_tot;
 	list_move_tail(&e->lru_list, &t->lru_list);
 }
 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
netfilter 00/08: netfilter update, Patrick McHardy, (Wed Feb 24, 10:49 am)
netfilter 02/08: xt_recent: fix buffer overflow, Patrick McHardy, (Wed Feb 24, 10:49 am)
netfilter 03/08: xt_recent: fix false match, Patrick McHardy, (Wed Feb 24, 10:49 am)
netfilter 04/08: xtables: replace XT_ENTRY_ITERATE macro, Patrick McHardy, (Wed Feb 24, 10:49 am)
netfilter 06/08: xtables: replace XT_MATCH_ITERATE macro, Patrick McHardy, (Wed Feb 24, 10:49 am)
netfilter 08/08: xtables: reduce arguments to translate_table, Patrick McHardy, (Wed Feb 24, 10:49 am)
Re: netfilter 00/08: netfilter update, Shan Wei, (Wed Feb 24, 6:36 pm)
Re: netfilter 00/08: netfilter update, Patrick McHardy, (Thu Feb 25, 10:35 am)