netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Question] integer overflow in function __qdisc_calculate_pkt_len()
@ 2023-06-02  2:50 luwei (O)
  2023-06-05 23:19 ` Jakub Kicinski
  0 siblings, 1 reply; 5+ messages in thread
From: luwei (O) @ 2023-06-02  2:50 UTC (permalink / raw)
  To: Networking

Hi list,

     I found an integer overflow issue in function 
__qdisc_calculate_pkt_len(), the root cause is overhead and cell_align 
in stab is not checked.

For example, if overhead is set to -2147483559 and cell_align is set to 
-32767 (tc tool limit it to 0 and -1, but other values can be set with 
netlink api),

the integer overflow occurs:

  568 void __qdisc_calculate_pkt_len(struct sk_buff *skb,
  569                                const struct qdisc_size_table *stab)
  570 {
  571         int pkt_len, slot;
  572
  573         pkt_len = skb->len + stab->szopts.overhead; (1)
  574         if (unlikely(!stab->szopts.tsize))
  575                 goto out;
  576
  577         slot = pkt_len + stab->szopts.cell_align;   (2)
  578         if (unlikely(slot < 0))
  579                 slot = 0;

if skb->len is 66, slot will be 66 + (-2147483559) + (-32767) = 
2147451036, and pkt_len will be 2147451040 finally.  I think the value 
of overhead and cell_align

should be limited, but not sure to which values they should be limited, 
can any one give me some suggestions?








-- 
Best Regards,
Lu Wei


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-06-25  2:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-02  2:50 [Question] integer overflow in function __qdisc_calculate_pkt_len() luwei (O)
2023-06-05 23:19 ` Jakub Kicinski
2023-06-06 12:54   ` luwei (O)
2023-06-06 15:49     ` Jakub Kicinski
2023-06-25  2:19       ` luwei (O)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).