Skip to content

Commit 9c706a4

Browse files
Uwe Kleine-Königdavem330
authored andcommitted
net: ipconfig: fix use after free
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 <[email protected]> Signed-off-by: Uwe Kleine-König <[email protected]> Tested-by: Geert Uytterhoeven <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0184165 commit 9c706a4

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

net/ipv4/ipconfig.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,14 +1492,6 @@ static int __init ip_auto_config(void)
14921492
if (ic_defaults() < 0)
14931493
return -1;
14941494

1495-
/*
1496-
* Close all network devices except the device we've
1497-
* autoconfigured and set up routes.
1498-
*/
1499-
ic_close_devs();
1500-
if (ic_setup_if() < 0 || ic_setup_routes() < 0)
1501-
return -1;
1502-
15031495
/*
15041496
* Record which protocol was actually used.
15051497
*/
@@ -1534,6 +1526,15 @@ static int __init ip_auto_config(void)
15341526
pr_cont("\n");
15351527
#endif /* !SILENT */
15361528

1529+
/*
1530+
* Close all network devices except the device we've
1531+
* autoconfigured and set up routes.
1532+
*/
1533+
ic_close_devs();
1534+
if (ic_setup_if() < 0 || ic_setup_routes() < 0)
1535+
return -1;
1536+
1537+
15371538
return 0;
15381539
}
15391540

0 commit comments

Comments
 (0)