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: <20200408064451.GE3310@unreal>
Date:   Wed, 8 Apr 2020 09:44:51 +0300
From:   Leon Romanovsky <leon@...nel.org>
To:     Ka-Cheong Poon <ka-cheong.poon@...cle.com>
Cc:     netdev@...r.kernel.org, santosh.shilimkar@...cle.com,
        davem@...emloft.net, rds-devel@....oracle.com,
        sironhide0null@...il.com
Subject: Re: [PATCH net 1/2] net/rds: Replace direct refcount_inc() by inline
 function

On Wed, Apr 08, 2020 at 12:15:51PM +0800, Ka-Cheong Poon wrote:
> On 4/8/20 2:48 AM, Leon Romanovsky wrote:
> > On Tue, Apr 07, 2020 at 09:08:01AM -0700, Ka-Cheong Poon wrote:
> > > Added rds_ib_dev_get() and rds_mr_get() to improve code readability.
> >
> > It is very hard to agree with this sentence.
> > Hiding basic kernel primitives is very rare will improve code readability.
> > It is definitely not the case here.
>
>
> This is to match the rds_ib_dev_put() and rds_mr_put() functions.
> Isn't it natural to have a pair of *_put()/*_get() functions?

Ohhh, thank you for pointing that. It is great example why hiding basic
primitives is really bad idea.

123 void rds_ib_dev_put(struct rds_ib_device *rds_ibdev)
124 {
125         BUG_ON(refcount_read(&rds_ibdev->refcount) == 0);
            ^^^^^^ no to this
126         if (refcount_dec_and_test(&rds_ibdev->refcount))
127                 queue_work(rds_wq, &rds_ibdev->free_work);
128 }

....

300         rds_ib_dev_put(rds_ibdev);
301         rds_ib_dev_put(rds_ibdev);

Double put -> you wrongly initialized/used refcount.

So instead of hiding refcount_inc(), I would say delete your *_put() variants,
fix reference counting and convert rds_mr_put() to be normal kref object
instead of current implementation. Which does exactly the same like your
custom *_put()/_get(), but better and with less errors.

Thanks

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ