Skip to content

Commit 6471db3

Browse files
M A RamdhansfX-bot
authored andcommitted
net/sched: cls_fw: Fix improper refcount update leads to use-after-free
[ Upstream commit 0323bce598eea038714f941ce2b22541c46d488f ] In the event of a failure in tcf_change_indev(), fw_set_parms() will immediately return an error after incrementing or decrementing reference counter in tcf_bind_filter(). If attacker can control reference counter to zero and make reference freed, leading to use after free. In order to prevent this, move the point of possible failure above the point where the TC_FW_CLASSID is handled. Fixes: 1da177e ("Linux-2.6.12-rc2") Reported-by: M A Ramdhan <[email protected]> Signed-off-by: M A Ramdhan <[email protected]> Acked-by: Jamal Hadi Salim <[email protected]> Reviewed-by: Pedro Tammela <[email protected]> Message-ID: <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 043241d commit 6471db3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

net/sched/cls_fw.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,6 @@ static int fw_set_parms(struct net *net, struct tcf_proto *tp,
210210
if (err < 0)
211211
return err;
212212

213-
if (tb[TCA_FW_CLASSID]) {
214-
f->res.classid = nla_get_u32(tb[TCA_FW_CLASSID]);
215-
tcf_bind_filter(tp, &f->res, base);
216-
}
217-
218213
if (tb[TCA_FW_INDEV]) {
219214
int ret;
220215
ret = tcf_change_indev(net, tb[TCA_FW_INDEV], extack);
@@ -231,6 +226,11 @@ static int fw_set_parms(struct net *net, struct tcf_proto *tp,
231226
} else if (head->mask != 0xFFFFFFFF)
232227
return err;
233228

229+
if (tb[TCA_FW_CLASSID]) {
230+
f->res.classid = nla_get_u32(tb[TCA_FW_CLASSID]);
231+
tcf_bind_filter(tp, &f->res, base);
232+
}
233+
234234
return 0;
235235
}
236236

0 commit comments

Comments
 (0)