Skip to content

Commit

Permalink
fib_trie: Avoid NULL pointer if local table is not allocated
Browse files Browse the repository at this point in the history
The function fib_unmerge assumed the local table had already been
allocated.  If that is not the case however when custom rules are applied
then this can result in a NULL pointer dereference.

In order to prevent this we must check the value of the local table pointer
and if it is NULL simply return 0 as there is no local table to separate
from the main.

Fixes: 0ddcf43 ("ipv4: FIB Local/MAIN table collapse")
Reported-by: Madhu Challa <challa@noironetworks.com>
Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Alexander Duyck authored and David S. Miller committed Mar 12, 2015
1 parent 80f1d68 commit 3c9e9f7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion net/ipv4/fib_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,12 @@ int fib_unmerge(struct net *net)
{
struct fib_table *old, *new;

/* attempt to fetch local table if it has been allocated */
old = fib_get_table(net, RT_TABLE_LOCAL);
new = fib_trie_unmerge(old);
if (!old)
return 0;

new = fib_trie_unmerge(old);
if (!new)
return -ENOMEM;

Expand Down

0 comments on commit 3c9e9f7

Please sign in to comment.