Skip to content

Commit

Permalink
net: ipconfig: fix use after free
Browse files Browse the repository at this point in the history
ic_close_devs() calls kfree() for all devices's ic_device. Since commit
2647cff ("net: ipconfig: Support using "delayed" DHCP replies")
the active device's ic_device is still used however to print the
ipconfig summary which results in an oops if the memory is already
changed. So delay freeing until after the autoconfig results are
reported.

Fixes: 2647cff ("net: ipconfig: Support using "delayed" DHCP replies")
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Uwe Kleine-König authored and David S. Miller committed Aug 10, 2016
1 parent 0184165 commit 9c706a4
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions net/ipv4/ipconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -1492,14 +1492,6 @@ static int __init ip_auto_config(void)
if (ic_defaults() < 0)
return -1;

/*
* Close all network devices except the device we've
* autoconfigured and set up routes.
*/
ic_close_devs();
if (ic_setup_if() < 0 || ic_setup_routes() < 0)
return -1;

/*
* Record which protocol was actually used.
*/
Expand Down Expand Up @@ -1534,6 +1526,15 @@ static int __init ip_auto_config(void)
pr_cont("\n");
#endif /* !SILENT */

/*
* Close all network devices except the device we've
* autoconfigured and set up routes.
*/
ic_close_devs();
if (ic_setup_if() < 0 || ic_setup_routes() < 0)
return -1;


return 0;
}

Expand Down

0 comments on commit 9c706a4

Please sign in to comment.