All of lore.kernel.org
 help / color / mirror / Atom feed
* [net-next PATCH] fib_trie: Fix regression in handling of inflate/halve failure
@ 2015-03-23 18:51 Alexander Duyck
  2015-03-23 20:59 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Duyck @ 2015-03-23 18:51 UTC (permalink / raw)
  To: netdev; +Cc: davem

When I updated the code to address a possible null pointer dereference in
resize I ended up reverting an exception handling fix for the suffix length
in the event that inflate or halve failed.  This change is meant to correct
that by reverting the earlier fix and instead simply getting the parent
again after inflate has been completed to avoid the possible null pointer
issue.

Fixes: ddb4b9a13 ("fib_trie: Address possible NULL pointer dereference in resize")
Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
---
 net/ipv4/fib_trie.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index e3b4aee..2c7c299 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -830,7 +830,7 @@ static struct key_vector *resize(struct trie *t, struct key_vector *tn)
 	/* Double as long as the resulting node has a number of
 	 * nonempty nodes that are above the threshold.
 	 */
-	while (should_inflate(tp, tn) && max_work--) {
+	while (should_inflate(tp, tn) && max_work) {
 		tp = inflate(t, tn);
 		if (!tp) {
 #ifdef CONFIG_IP_FIB_TRIE_STATS
@@ -839,17 +839,21 @@ static struct key_vector *resize(struct trie *t, struct key_vector *tn)
 			break;
 		}
 
+		max_work--;
 		tn = get_child(tp, cindex);
 	}
 
+	/* update parent in case inflate failed */
+	tp = node_parent(tn);
+
 	/* Return if at least one inflate is run */
 	if (max_work != MAX_WORK)
-		return node_parent(tn);
+		return tp;
 
 	/* Halve as long as the number of empty children in this
 	 * node is above threshold.
 	 */
-	while (should_halve(tp, tn) && max_work--) {
+	while (should_halve(tp, tn) && max_work) {
 		tp = halve(t, tn);
 		if (!tp) {
 #ifdef CONFIG_IP_FIB_TRIE_STATS
@@ -858,6 +862,7 @@ static struct key_vector *resize(struct trie *t, struct key_vector *tn)
 			break;
 		}
 
+		max_work--;
 		tn = get_child(tp, cindex);
 	}
 
@@ -865,7 +870,7 @@ static struct key_vector *resize(struct trie *t, struct key_vector *tn)
 	if (should_collapse(tn))
 		return collapse(t, tn);
 
-	/* update parent in case inflate or halve failed */
+	/* update parent in case halve failed */
 	tp = node_parent(tn);
 
 	/* Return if at least one deflate was run */

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [net-next PATCH] fib_trie: Fix regression in handling of inflate/halve failure
  2015-03-23 18:51 [net-next PATCH] fib_trie: Fix regression in handling of inflate/halve failure Alexander Duyck
@ 2015-03-23 20:59 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-03-23 20:59 UTC (permalink / raw)
  To: alexander.h.duyck; +Cc: netdev

From: Alexander Duyck <alexander.h.duyck@redhat.com>
Date: Mon, 23 Mar 2015 11:51:53 -0700

> When I updated the code to address a possible null pointer dereference in
> resize I ended up reverting an exception handling fix for the suffix length
> in the event that inflate or halve failed.  This change is meant to correct
> that by reverting the earlier fix and instead simply getting the parent
> again after inflate has been completed to avoid the possible null pointer
> issue.
> 
> Fixes: ddb4b9a13 ("fib_trie: Address possible NULL pointer dereference in resize")
> Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-23 20:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-23 18:51 [net-next PATCH] fib_trie: Fix regression in handling of inflate/halve failure Alexander Duyck
2015-03-23 20:59 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.