Patchwork [2/2] dcb: use after free in dcb_flushapp()

login
register
mail settings
Submitter Dan Carpenter
Date Jan. 5, 2011, 7:03 a.m.
Message ID <20110105070344.GB24847@bicker>
Download mbox | patch
Permalink /patch/77573/
State Accepted
Delegated to: David Miller
Headers show

Comments

Dan Carpenter - Jan. 5, 2011, 7:03 a.m.
The original code has a use after free bug because it's not using the
_safe() version of the list_for_each_entry() macro.

Signed-off-by: Dan Carpenter <error27@gmail.com>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Jan. 6, 2011, 7:17 p.m.
From: Dan Carpenter <error27@gmail.com>
Date: Wed, 5 Jan 2011 10:03:44 +0300

> The original code has a use after free bug because it's not using the
> _safe() version of the list_for_each_entry() macro.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Also applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 8881cb5..11bf6a2 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1650,9 +1650,10 @@  EXPORT_SYMBOL(dcb_setapp);
 static void dcb_flushapp(void)
 {
 	struct dcb_app_type *app;
+	struct dcb_app_type *tmp;
 
 	spin_lock(&dcb_lock);
-	list_for_each_entry(app, &dcb_app_list, list) {
+	list_for_each_entry_safe(app, tmp, &dcb_app_list, list) {
 		list_del(&app->list);
 		kfree(app);
 	}