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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Sun, 07 Mar 2021 20:27:44 -0800
From:   James Bottomley <jejb@...ux.ibm.com>
To:     Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>, lduncan@...e.com
Cc:     cleech@...hat.com, martin.petersen@...cle.com,
        open-iscsi@...glegroups.com, linux-scsi@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] scsi: iscsi: Switch to using the new API kobj_to_dev()

On Mon, 2021-03-08 at 11:34 +0800, Jiapeng Chong wrote:
> Fix the following coccicheck warnings:
> 
> ./drivers/scsi/scsi_transport_iscsi.c:930:60-61: WARNING opportunity
> for kobj_to_dev().

I have to ask, what is the point of this?  container_of is usually
pretty safe ... as in it will detect when you screw up the usage.  The
only real misuse you can get is when the input type has an object of
the same name and return type and you got confused between two objects
with this property, but misuses like this resulting in bugs are very,
very rare.

Usually we wrap container_of because the wrapping is a bit shorter as
you can see: kobj_to_dev is about half the size of the container_of
form ... but is there any other reason to do it?

The problem is that container_of is a standard way of doing cast outs
in the kernel and we have hundreds of them.  To be precise, in scsi
alone:

jejb@...vis:~/git/linux/drivers/scsi> git grep container_of|wc -l
496

So we really don't want to encourage wrapping them all because the
churn would be unbelievable and the gain minute.  So why should this
one case especially be wrapped when we don't want to wrap the others?

James


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ