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] [thread-next>] [day] [month] [year] [list]
Message-ID: <5489e3c5-30ad-d7af-c329-40c93d9a1b62@huaweicloud.com>
Date:   Tue, 29 Nov 2022 10:59:46 +0800
From:   Yu Kuai <yukuai1@...weicloud.com>
To:     Li Jinlin <lijinlin3@...wei.com>,
        Yu Kuai <yukuai1@...weicloud.com>, Tejun Heo <tj@...nel.org>
Cc:     josef@...icpanda.com, axboe@...nel.dk, cgroups@...r.kernel.org,
        linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
        liuzhiqiang26@...wei.com, "yukuai (C)" <yukuai3@...wei.com>
Subject: Re: [PATCH v2] blk-iocost: fix shift-out-of-bounds in
 iocg_hick_delay()

Hi,

在 2022/11/29 10:49, Li Jinlin 写道:
> 
> 
> On 2022/11/29 9:14, Yu Kuai wrote:
>> Hi,
>>
>> 在 2022/11/29 3:58, Tejun Heo 写道:
>>> On Mon, Nov 28, 2022 at 11:04:13AM +0800, Li Jinlin wrote:
>>>>        /* calculate the current delay in effect - 1/2 every second */
>>>>        tdelta = now->now - iocg->delay_at;
>>>>        if (iocg->delay)
>>>> -        delay = iocg->delay >> div64_u64(tdelta, USEC_PER_SEC);
>>>> +        delay = iocg->delay >>
>>>> +            min_t(u64, div64_u64(tdelta, USEC_PER_SEC), 63);
>>>
>>> I replied earlier but the right thing to do here is setting delay to 0 if
>>> the shift is >= 64.
>>
>> Perhaps following change will make more sense?
>>
>> @@ -1322,18 +1323,19 @@ static bool iocg_kick_delay(struct ioc_gq *iocg, struct ioc_now *now)
>>   {
>>          struct ioc *ioc = iocg->ioc;
>>          struct blkcg_gq *blkg = iocg_to_blkg(iocg);
>> -       u64 tdelta, delay, new_delay;
>> +       u64 delay = 0;
>> +       u64 new_delay;
>>          s64 vover, vover_pct;
>>          u32 hwa;
>>
>>          lockdep_assert_held(&iocg->waitq.lock);
>>
>>          /* calculate the current delay in effect - 1/2 every second */
>> -       tdelta = now->now - iocg->delay_at;
>> -       if (iocg->delay)
>> +       if (iocg->delay && now->now > iocg->delay_at) {
>> +               u64 tdelta = now->now - iocg->delay_at;
>> +
>>                  delay = iocg->delay >> div64_u64(tdelta, USEC_PER_SEC);
>> -       else
>> -               delay = 0;
>> +       }
>>
> I think "now->now > iocg->delay_at" is unnecessary, it is almost inevitable.

 From what I see, following can only happen if now->now < iocg->delay_at:

"shift exponent 18446744073709"

Or something else triggers it?

Thanks,
Kuai

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ