summaryrefslogtreecommitdiff
blob: 3fb091d0e099b6ad9eb4bcfe2c99424cc0c705f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From: Thomas Graf <tgraf@suug.ch>
Date: Sun, 25 Mar 2007 03:32:54 +0000 (-0700)
Subject: [IPv4] fib: Fix out of bound access of fib_props[]
X-Git-Tag: v2.6.21~241^2~12
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=a0ee18b9b7d3847976c6fb315c06a34fb296de0e

[IPv4] fib: Fix out of bound access of fib_props[]

Fixes a typo which caused fib_props[] to have the wrong size
and makes sure the value used to index the array which is
provided by userspace via netlink is checked to avoid out of
bound access.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
---

Backported to Debian's 2.6.18 by dann frazier <dannf@debian.org>, heavily
based upon Tim Gardner's backport for Ubuntu:
  http://kernel.ubuntu.com/git?p=ubuntu/ubuntu-edgy.git;a=commitdiff;h=6e87288e83ac08e7154980795622efdafd49c9c8

--- linux-source-2.6.18.orig/net/ipv4/fib_semantics.c	2006-09-19 21:42:06.000000000 -0600
+++ linux-source-2.6.18/net/ipv4/fib_semantics.c	2007-08-27 22:15:04.678316443 -0600
@@ -88,7 +88,7 @@ static const struct 
 {
 	int	error;
 	u8	scope;
-} fib_props[RTA_MAX + 1] = {
+} fib_props[RTN_MAX + 1] = {
         {
 		.error	= 0,
 		.scope	= RT_SCOPE_NOWHERE,
@@ -662,6 +662,9 @@ fib_create_info(const struct rtmsg *r, s
 	u32 mp_alg = IP_MP_ALG_NONE;
 #endif
 
+	if (r->rtm_type > RTN_MAX)
+		goto err_inval;
+
 	/* Fast check to catch the most weird cases */
 	if (fib_props[r->rtm_type].scope > r->rtm_scope)
 		goto err_inval;