Skip to content

Commit 819fcf4

Browse files
committed
Merge branch 'cls_drop-fix'
Jamal Hadi Salim says: ==================== net: dont intepret cls results when asked to drop It is possible that an error in processing may occur in tcf_classify() which will result in res.classid being some garbage value. Example of such a code path is when the classifier goes into a loop due to bad policy. See patch 1/2 for a sample splat. While the core code reacts correctly and asks the caller to drop the packet (by returning TC_ACT_SHOT) some callers first intepret the res.class as a pointer to memory and end up dropping the packet only after some activity with the pointer. There is likelihood of this resulting in an exploit. So lets fix all the known qdiscs that behave this way. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 91e2286 + caa4b35 commit 819fcf4

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

net/sched/sch_atm.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,13 @@ static int atm_tc_enqueue(struct sk_buff *skb, struct Qdisc *sch,
393393
result = tcf_classify(skb, NULL, fl, &res, true);
394394
if (result < 0)
395395
continue;
396+
if (result == TC_ACT_SHOT)
397+
goto done;
398+
396399
flow = (struct atm_flow_data *)res.class;
397400
if (!flow)
398401
flow = lookup_flow(sch, res.classid);
399-
goto done;
402+
goto drop;
400403
}
401404
}
402405
flow = NULL;

net/sched/sch_cbq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ cbq_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
230230
result = tcf_classify(skb, NULL, fl, &res, true);
231231
if (!fl || result < 0)
232232
goto fallback;
233+
if (result == TC_ACT_SHOT)
234+
return NULL;
233235

234236
cl = (void *)res.class;
235237
if (!cl) {
@@ -250,8 +252,6 @@ cbq_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
250252
case TC_ACT_TRAP:
251253
*qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
252254
fallthrough;
253-
case TC_ACT_SHOT:
254-
return NULL;
255255
case TC_ACT_RECLASSIFY:
256256
return cbq_reclassify(skb, cl);
257257
}

0 commit comments

Comments
 (0)