From: Matti Vaittinen <matti.vaittinen@nsn.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [PATCH net-next] IPV6 Fix a crash when trying to replace non existing route
Date: Thu, 17 Nov 2011 09:18:02 +0200 [thread overview]
Message-ID: <1321514282.1858.125.camel@hakki> (raw)
This patch fixes a crash when non existing IPv6 route is tried to be changed.
When new destination node was inserted in middle of FIB6 tree, no relevant
sanity checks were performed. Later route insertion might have been prevented
due to invalid request, causing node with no rt info being left in tree.
When this node was accessed, a crash occurred.
Patch adds missing checks in fib6_add_1()
Signed-off-by: Matti Vaittinen <Mazziesaccount@gmail.com>
--
diff -uNr net-next-229a66e.orig/net/ipv6/ip6_fib.c net-next-229a66e.new/net/ipv6/ip6_fib.c
--- net-next-229a66e.orig/net/ipv6/ip6_fib.c 2011-11-16 16:03:27.000000000 +0200
+++ net-next-229a66e.new/net/ipv6/ip6_fib.c 2011-11-16 16:15:25.000000000 +0200
@@ -449,9 +449,15 @@
*/
if (plen < fn->fn_bit ||
!ipv6_prefix_equal(&key->addr, addr, fn->fn_bit)) {
- if (!allow_create)
+ if (!allow_create) {
+ if (replace_required) {
+ printk(KERN_WARNING
+ "IPv6: Can't replace route, no match found\n");
+ return ERR_PTR(-ENOENT);
+ }
printk(KERN_WARNING
"IPv6: NLM_F_CREATE should be set when creating new route\n");
+ }
goto insert_above;
}
@@ -482,7 +488,7 @@
fn = dir ? fn->right: fn->left;
} while (fn);
- if (replace_required && !allow_create) {
+ if (!allow_create) {
/* We should not create new node because
* NLM_F_REPLACE was specified without NLM_F_CREATE
* I assume it is safe to require NLM_F_CREATE when
@@ -492,16 +498,17 @@
* MUST be specified if new route is created.
* That would keep IPv6 consistent with IPv4
*/
- printk(KERN_WARNING
- "IPv6: NLM_F_CREATE should be set when creating new route - ignoring request\n");
- return ERR_PTR(-ENOENT);
+ if (replace_required) {
+ printk(KERN_WARNING
+ "IPv6: Can't replace route, no match found\n");
+ return ERR_PTR(-ENOENT);
+ }
+ printk(KERN_WARNING "IPv6: NLM_F_CREATE should be set when creating new route\n");
}
/*
* We walked to the bottom of tree.
* Create new leaf node without children.
*/
- if (!allow_create)
- printk(KERN_WARNING "IPv6: NLM_F_CREATE should be set when creating new route\n");
ln = node_alloc();
next reply other threads:[~2011-11-17 7:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-17 7:18 Matti Vaittinen [this message]
2011-11-17 8:19 ` [PATCH net-next] IPV6 Fix a crash when trying to replace non existing route David Miller
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=1321514282.1858.125.camel@hakki \
--to=matti.vaittinen@nsn.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).