From: Cong Wang Date: Mon, 3 Sep 2018 18:08:15 +0000 (-0700) Subject: act_ife: fix a potential use-after-free X-Git-Tag: v4.14.70~115 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a08d7ea10bc7df3b0177d7de2aab3805899fb8fd;p=users%2Fjedix%2Flinux-maple.git act_ife: fix a potential use-after-free [ Upstream commit 6d784f1625ea68783cc1fb17de8f6cd3e1660c3f ] 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 Signed-off-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c index 85757af7f1508..711ccc4607cc5 100644 --- a/net/sched/act_ife.c +++ b/net/sched/act_ife.c @@ -377,7 +377,6 @@ static void _tcf_ife_cleanup(struct tc_action *a, int bind) 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) @@ -385,6 +384,7 @@ static void _tcf_ife_cleanup(struct tc_action *a, int bind) else kfree(e->metaval); } + module_put(e->ops->owner); kfree(e); } }