Skip to contentSkip to conversation

act_ife: fix a potential use-after-free

PATCH In review Cong Wang 2 participants 2 messages Sep 3, 2018 – Sep 4, 2018

Subsystems (3)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 act_ife: fix a potential use-after-free

Immediately after module_put(), user could delete this module, so e->ops could be already freed before we call e->ops->release().

Fix this by moving module_put() after ops->release().

Fixes ef6980b6becb ("introduce IFE action")
Cc Jamal Hadi Salim <[email protected]>
---
 net/sched/act_ife.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/act_ife.c +1 -1
index 196430aefe87..fc412769a1be 100644
@@ -400,7 +400,6 @@ static void _tcf_ife_cleanup(struct tc_action *a)
 	struct tcf_meta_info *e, *n;
 
 	list_for_each_entry_safe(e, n, &ife->metalist, metalist) {
-		module_put(e->ops->owner);
 		list_del(&e->metalist);
 		if (e->metaval) {
 			if (e->ops->release)
@@ -408,6 +407,7 @@ static void _tcf_ife_cleanup(struct tc_action *a)
 			else
 				kfree(e->metaval);
 		}
+		module_put(e->ops->owner);
 		kfree(e);
 	}
 }
Signature · 1 line
2.14.4
maintainer
#1 lore raw

From: Cong Wang <[email protected]>
Date: Mon, 3 Sep 2018 11:08:15 -0700

Quoted 8 lines

Immediately after module_put(), user could delete this module, so e->ops could be already freed before we call e->ops->release().

Fix this by moving module_put() after ops->release().

Fixes ef6980b6becb ("introduce IFE action")

Applied and queued up for -stable, thanks Cong.