lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <374426a9-2739-9aab-4ee4-ef31dab402a2@huawei.com>
Date: Sun, 25 Jun 2023 10:19:45 +0800
From: "luwei (O)" <luwei32@...wei.com>
To: Jakub Kicinski <kuba@...nel.org>
CC: Networking <netdev@...r.kernel.org>
Subject: Re: [Question] integer overflow in function
 __qdisc_calculate_pkt_len()


在 2023/6/6 11:49 PM, Jakub Kicinski 写道:
> On Tue, 6 Jun 2023 20:54:47 +0800 luwei (O) wrote:
>>> on a quick look limiting the cell_align to S16_MIN at the netlink level
>>> (NLA_POLICY_MIN()) seems reasonable, feel free to send a patch.
>>> .
>> Thanks for your reply, but do your mean cell_align or overhead? It seems
>> limit cell_align to
>>
>> S16_MIN(-32768) can still cause the overflow:
>>
>>       66 + (-2147483559) + (-32767) = 2147451036
>>
>>     skb->len = 66
>>     stab->szopts.overhead = -2147483559
>>     stab->szopts.cell_align = -32767
> Could you explain what the problem caused by the overflow will be?

yes, it affects the final result of pkt_len in 
__qdisc_calculate_pkt_len().  In the previous example, the final pkt_len 
will be 2147451040

which is very different from the origin skb->len 66 and it will reduce 
traffic control accuracy heavily.

it is calculated as follows:

void __qdisc_calculate_pkt_len(struct sk_buff *skb,
                                const struct qdisc_size_table *stab)
{
         int pkt_len, slot;

         pkt_len = skb->len + stab->szopts.overhead;     // pkt_len = 66 
+ (-2147483559) = -2147483493
         if (unlikely(!stab->szopts.tsize))
                 goto out;

         slot = pkt_len + stab->szopts.cell_align;            // slot  = 
-2147483493 + (-32767) = 2147451036
         if (unlikely(slot < 0))
                 slot = 0;

         slot >>= stab->szopts.cell_log;          slot  =  2147451036 
 >>  2 =  536862759
         if (likely(slot < stab->szopts.tsize))
                 pkt_len = stab->data[slot];
         else
                 pkt_len = stab->data[stab->szopts.tsize - 1] *
                                 (slot / stab->szopts.tsize) +
                                 stab->data[slot % 
stab->szopts.tsize];    // pkt_len  = 2048 * (536862759 / 512) + 160 = 
2147451040

         pkt_len <<= stab->szopts.size_log;
out:
         if (unlikely(pkt_len < 1))
                 pkt_len = 1;
         qdisc_skb_cb(skb)->pkt_len = pkt_len;
}
EXPORT_SYMBOL(__qdisc_calculate_pkt_len);
> .

-- 
Best Regards,
Lu Wei


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ