Skip to content

Commit 2064a27

Browse files
committed
net/sched: cls_fw: Fix improper refcount update leads to use-after-free
jira LE-1907 cve CVE-2023-3776 Rebuild_History Non-Buildable kernel-5.14.0-284.30.1.el9_2 commit-author M A Ramdhan <[email protected]> commit 0323bce 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]> (cherry picked from commit 0323bce) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 075c8d3 commit 2064a27

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)