From: Patryk Mungai <patryk.mungai-ndungu.kx@renesas.com> To: stable@vger.kernel.org Cc: davem@davemloft.net, cip-dev@lists.cip-project.org, "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>, "Patryk Mungai" <patryk.mungai-ndungu.kx@renesas.com> Subject: [PATCH 4.4 3/5] net: ipconfig: fix use after free Date: Fri, 5 Apr 2019 11:47:34 +0100 [thread overview] Message-ID: <1554461256-12966-4-git-send-email-patryk.mungai-ndungu.kx@renesas.com> (raw) In-Reply-To: <1554461256-12966-1-git-send-email-patryk.mungai-ndungu.kx@renesas.com> From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> commit 9c706a49d660653625d206f6972541c1f60ea2b0 upstream. ic_close_devs() calls kfree() for all devices's ic_device. Since commit 2647cffb2bc6 ("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: 2647cffb2bc6 ("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> [Patryk: cherry-picked to 4.4] Signed-off-by: Patryk Mungai <patryk.mungai-ndungu.kx@renesas.com> --- net/ipv4/ipconfig.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 35c8b35..23c9b8a 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -1519,14 +1519,6 @@ static int __init ip_auto_config(void) 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. */ #ifdef IPCONFIG_DYNAMIC @@ -1560,6 +1552,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; } -- 2.7.4
WARNING: multiple messages have this Message-ID (diff)
From: patryk.mungai-ndungu.kx@renesas.com (Patryk Mungai) To: cip-dev@lists.cip-project.org Subject: [cip-dev] [PATCH 4.4 3/5] net: ipconfig: fix use after free Date: Fri, 5 Apr 2019 11:47:34 +0100 [thread overview] Message-ID: <1554461256-12966-4-git-send-email-patryk.mungai-ndungu.kx@renesas.com> (raw) In-Reply-To: <1554461256-12966-1-git-send-email-patryk.mungai-ndungu.kx@renesas.com> From: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de> commit 9c706a49d660653625d206f6972541c1f60ea2b0 upstream. ic_close_devs() calls kfree() for all devices's ic_device. Since commit 2647cffb2bc6 ("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: 2647cffb2bc6 ("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> [Patryk: cherry-picked to 4.4] Signed-off-by: Patryk Mungai <patryk.mungai-ndungu.kx@renesas.com> --- net/ipv4/ipconfig.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 35c8b35..23c9b8a 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -1519,14 +1519,6 @@ static int __init ip_auto_config(void) 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. */ #ifdef IPCONFIG_DYNAMIC @@ -1560,6 +1552,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; } -- 2.7.4
next prev parent reply other threads:[~2019-04-05 10:48 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-04-05 10:47 [PATCH 4.4 0/5] DHCP client support when receiving "delayed" replies Patryk Mungai 2019-04-05 10:47 ` [cip-dev] " Patryk Mungai 2019-04-05 10:47 ` [PATCH 4.4 1/5] net: ipconfig: Support using "delayed" DHCP replies Patryk Mungai 2019-04-05 10:47 ` [cip-dev] " Patryk Mungai 2019-04-05 10:47 ` [PATCH 4.4 2/5] net: ipconfig: drop inter-device timeout Patryk Mungai 2019-04-05 10:47 ` [cip-dev] " Patryk Mungai 2019-04-05 10:47 ` Patryk Mungai [this message] 2019-04-05 10:47 ` [cip-dev] [PATCH 4.4 3/5] net: ipconfig: fix use after free Patryk Mungai 2019-04-05 10:47 ` [PATCH 4.4 4/5] net: ipconfig: Fix more " Patryk Mungai 2019-04-05 10:47 ` [cip-dev] " Patryk Mungai 2019-04-05 10:47 ` [PATCH 4.4 5/5] net: ipconfig: Fix NULL pointer dereference on RARP/BOOTP/DHCP timeout Patryk Mungai 2019-04-05 10:47 ` [cip-dev] " Patryk Mungai 2019-04-06 10:38 ` [cip-dev] [PATCH 4.4 0/5] DHCP client support when receiving "delayed" replies Pavel Machek 2019-04-06 10:38 ` Pavel Machek 2019-04-09 9:10 ` Patryk Mungai Ndungu 2019-04-09 9:10 ` Patryk Mungai Ndungu 2019-04-06 13:53 ` Sasha Levin 2019-04-06 13:53 ` [cip-dev] " Sasha Levin 2019-04-24 16:44 ` Greg KH 2019-04-24 16:44 ` [cip-dev] " Greg KH
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=1554461256-12966-4-git-send-email-patryk.mungai-ndungu.kx@renesas.com \ --to=patryk.mungai-ndungu.kx@renesas.com \ --cc=cip-dev@lists.cip-project.org \ --cc=davem@davemloft.net \ --cc=stable@vger.kernel.org \ --cc=u.kleine-koenig@pengutronix.de \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.