mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Patrick McHardy <kaber@trash.net>
Subject: [5/9] netfilter: nf_ct_ftp: fix out of bounds read in update_nl_seq()
Date: Thu, 14 Jan 2010 14:46:41 -0800	[thread overview]
Message-ID: <20100114224806.913050712@mini.kroah.org> (raw)
In-Reply-To: <20100114224848.GA532@kroah.com>

2.6.31-stable review patch.  If anyone has any objections, please let us know.

------------------

From: Patrick McHardy <kaber@trash.net>

commit aaff23a95aea5f000895f50d90e91f1e2f727002 upstream.

As noticed by Dan Carpenter <error27@gmail.com>, update_nl_seq()
currently contains an out of bounds read of the seq_aft_nl array
when looking for the oldest sequence number position.

Fix it to only compare valid positions.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 net/netfilter/nf_conntrack_ftp.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

--- a/net/netfilter/nf_conntrack_ftp.c
+++ b/net/netfilter/nf_conntrack_ftp.c
@@ -323,24 +323,24 @@ static void update_nl_seq(struct nf_conn
 			  struct nf_ct_ftp_master *info, int dir,
 			  struct sk_buff *skb)
 {
-	unsigned int i, oldest = NUM_SEQ_TO_REMEMBER;
+	unsigned int i, oldest;
 
 	/* Look for oldest: if we find exact match, we're done. */
 	for (i = 0; i < info->seq_aft_nl_num[dir]; i++) {
 		if (info->seq_aft_nl[dir][i] == nl_seq)
 			return;
-
-		if (oldest == info->seq_aft_nl_num[dir] ||
-		    before(info->seq_aft_nl[dir][i],
-			   info->seq_aft_nl[dir][oldest]))
-			oldest = i;
 	}
 
 	if (info->seq_aft_nl_num[dir] < NUM_SEQ_TO_REMEMBER) {
 		info->seq_aft_nl[dir][info->seq_aft_nl_num[dir]++] = nl_seq;
-	} else if (oldest != NUM_SEQ_TO_REMEMBER &&
-		   after(nl_seq, info->seq_aft_nl[dir][oldest])) {
-		info->seq_aft_nl[dir][oldest] = nl_seq;
+	} else {
+		if (before(info->seq_aft_nl[dir][0], info->seq_aft_nl[dir][1]))
+			oldest = 0;
+		else
+			oldest = 1;
+
+		if (after(nl_seq, info->seq_aft_nl[dir][oldest]))
+			info->seq_aft_nl[dir][oldest] = nl_seq;
 	}
 }
 



  parent reply	other threads:[~2010-01-14 22:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-14 22:48 [0/9] 2.6.31.12-stable review Greg KH
2010-01-14 22:46 ` [1/9] fasync: split fasync_helper() into separate add/remove functions Greg KH
2010-01-14 22:46 ` [2/9] hwmon: (adt7462) Fix pin 28 monitoring Greg KH
2010-01-14 22:46 ` [3/9] kernel/signal.c: fix kernel information leak with print-fatal-signals=1 Greg KH
2010-01-14 22:46 ` [4/9] netfilter: ebtables: enforce CAP_NET_ADMIN Greg KH
2010-01-14 22:46 ` Greg KH [this message]
2010-01-14 22:46 ` [6/9] quota: Fix dquot_transfer for filesystems different from ext4 Greg KH
2010-01-14 22:46 ` [7/9] fix braindamage in audit_tree.c untag_chunk() Greg KH
2010-01-14 22:46 ` [8/9] fix more leaks in audit_tree.c tag_chunk() Greg KH
2010-01-14 22:46 ` [9/9] ipv6: skb_dst() can be NULL in ipv6_hop_jumbo() Greg KH
2010-01-16 19:03 ` [0/9] 2.6.31.12-stable review Ozan Çağlayan
2010-01-16 19:07   ` H. Peter Anvin
2010-01-17  3:23   ` [stable] " Greg KH
2010-01-17 16:07     ` Ozan Çağlayan
2010-01-17 16:18       ` Greg KH
2010-01-17 16:30         ` Ozan Çağlayan
2010-01-17 18:02         ` Henrique de Moraes Holschuh
2010-01-18  5:42           ` Greg KH
2010-01-18  7:49         ` [Stable-review] " Nikola Ciprich
2010-01-19  4:07           ` [stable] [Stable-review] " Greg KH
2010-01-19 23:02     ` [stable] " Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100114224806.913050712@mini.kroah.org \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=kaber@trash.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome