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]
Date:   Fri, 2 Oct 2020 17:50:09 -0600
From:   Shuah Khan <skhan@...uxfoundation.org>
To:     Jens Axboe <axboe@...nel.dk>, idryomov@...il.com,
        dongsheng.yang@...ystack.cn
Cc:     ceph-devel@...r.kernel.org,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Kees Cook <keescook@...omium.org>,
        Shuah Khan <skhan@...uxfoundation.org>
Subject: Re: drivers/block/rbd.c: atomic_inc_return_safe() &
 atomic_dec_return_safe()

On 10/2/20 5:44 PM, Jens Axboe wrote:
> On 10/2/20 4:34 PM, Shuah Khan wrote:
>> All,
>>
>> I came across these atomic_inc_return_safe() & atomic_dec_return_safe()
>> functions that hold the counters at safe values.
>>
>> atomic_inc_return_safe()
>>
>> If the counter is already 0 it will not be incremented.
>> If the counter is already at its maximum value returns
>> -EINVAL without updating it.
>>
>> atomic_dec_return_safe()
>>
>> Decrement the counter.  Return the resulting value, or -EINVAL
>>
>> These two routines are static and only used in rbd.c.
>>
>> Can these become part of atomic_t ops?
> 
> I think you just want to use refcount_t for this use case. They
> have safe guards for under/overflow.
> 

Makes sense. Guess these came before refcount_t.

I will track this for refcount_t conversion.

thanks,
-- Shuah

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ