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: <21843836-7265-f903-a7d5-e77b07dd5a71@huaweicloud.com>
Date:   Sun, 8 Oct 2023 09:26:25 +0800
From:   Yu Kuai <yukuai1@...weicloud.com>
To:     Oleg Nesterov <oleg@...hat.com>, Yu Kuai <yukuai1@...weicloud.com>
Cc:     Li Nan <linan666@...weicloud.com>,
        Khazhy Kumykov <khazhy@...omium.org>, tj@...nel.org,
        josef@...icpanda.com, axboe@...nel.dk, cgroups@...r.kernel.org,
        linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
        yi.zhang@...wei.com, houtao1@...wei.com, yangerkun@...wei.com,
        "yukuai (C)" <yukuai3@...wei.com>
Subject: Re: [PATCH] blk-throttle: Calculate allowed value only when the
 throttle is enabled

Hi,

在 2023/10/07 23:16, Oleg Nesterov 写道:
> On 10/07, Yu Kuai wrote:
>>
>>>>> probably need to remove the mul_u64_u64_div_u64 and check for
>>>>> overflow/potential overflow ourselves?
>>>
>>> probably yes...
>>
>> How about this?
>>
>> diff --git a/block/blk-throttle.c b/block/blk-throttle.c
>> index 1101fb6f6cc8..5482c316a103 100644
>> --- a/block/blk-throttle.c
>> +++ b/block/blk-throttle.c
>> @@ -723,6 +723,10 @@ static unsigned int calculate_io_allowed(u32
>> iops_limit,
>>
>>   static u64 calculate_bytes_allowed(u64 bps_limit, unsigned long
>> jiffy_elapsed)
>>   {
>> +       if (jiffy_elapsed > HZ &&
>> +           bps_limit > mul_u64_u64_div_u64(U64_MAX, (u64)HZ,
>> (u64)jiffy_elapsed);
>> +               return U64_MAX;
>> +
> 
> I can't suggest anything better...
> 
> but I do not know if it is possible that HZ > jiffy_elapsed. If yes, then
> mul_u64_u64_div_u64() above is not safe too.

Well, 'jiffy_elapsed > HZ' is judged before mul_u64_u64_div_u64().

Overflow can only happen if the above 2 conditions passed, and U64_MAX
is returned.

Thanks,
Kuai

> 
> Oleg.
> 
> .
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ