summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorTim Gardner <tim.gardner@canonical.com>2010-02-23 14:55:21 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-15 08:50:00 -0700
commit6f2deb6aad5e242d5573ae8d98a90a454f5e79d0 (patch)
treeed7d736688887e3d24ce6c4ec937db48cc7f1e0a /net
parent81fc8e0872c9f00ee7fb01305822758cb4bb8a2d (diff)
netfilter: xt_recent: fix buffer overflow
commit 2c08522e5d2f0af2d6f05be558946dcbf8173683 upstream. 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> Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'net')
-rw-r--r--net/netfilter/xt_recent.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
index eb0ceb846527..d940a6367c7a 100644
--- a/net/netfilter/xt_recent.c
+++ b/net/netfilter/xt_recent.c
@@ -173,10 +173,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);
}