Skip to content

Commit

Permalink
net: sched: Fix a possible null-pointer dereference in dequeue_func()
Browse files Browse the repository at this point in the history
In dequeue_func(), there is an if statement on line 74 to check whether
skb is NULL:
    if (skb)

When skb is NULL, it is used on line 77:
    prefetch(&skb->end);

Thus, a possible null-pointer dereference may occur.

To fix this bug, skb->end is used when skb is not NULL.

This bug is found by a static analysis tool STCheck written by us.

Fixes: 76e3cc1 ("codel: Controlled Delay AQM")
Signed-off-by: Jia-Ju Bai <[email protected]>
Reviewed-by: Jiri Pirko <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
XidianGeneral authored and davem330 committed Jul 29, 2019
1 parent a7f9cbf commit 051c7b3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net/sched/sch_codel.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ static struct sk_buff *dequeue_func(struct codel_vars *vars, void *ctx)
struct Qdisc *sch = ctx;
struct sk_buff *skb = __qdisc_dequeue_head(&sch->q);

if (skb)
if (skb) {
sch->qstats.backlog -= qdisc_pkt_len(skb);

prefetch(&skb->end); /* we'll need skb_shinfo() */
prefetch(&skb->end); /* we'll need skb_shinfo() */
}
return skb;
}

Expand Down

0 comments on commit 051c7b3

Please sign in to comment.