Skip to contentSkip to conversation

fib: Fix out of bound access of fib_props[]

IPv4 Thomas Graf 1 participant 1 message Nov 29, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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.

net/ipv4/fib_semantics.c +4 -1
Index: net-2.6/net/ipv4/fib_semantics.c
===================================================================
@@ -89,7 +89,7 @@
 {
 	int	error;
 	u8	scope;
-} fib_props[RTA_MAX + 1] = {
+} fib_props[RTN_MAX + 1] = {
         {
 		.error	= 0,
 		.scope	= RT_SCOPE_NOWHERE,
@@ -658,6 +658,9 @@
 	struct fib_info *ofi;
 	int nhs = 1;
 
+	if (cfg->fc_type > RTN_MAX)
+		goto err_inval;
+
 	/* Fast check to catch the most weird cases */
 	if (fib_props[cfg->fc_type].scope > cfg->fc_scope)
 		goto err_inval;