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: <9063649a-23a4-4c33-bdc4-f6f82fdef1e3@kili.mountain>
Date:   Mon, 8 May 2023 09:08:37 +0300
From:   Dan Carpenter <dan.carpenter@...aro.org>
To:     Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc:     Vinod Koul <vkoul@...nel.org>, linux-kernel@...r.kernel.org,
        kernel-janitors@...r.kernel.org, dmaengine@...r.kernel.org
Subject: Re: [PATCH] dmaengine: mcf-edma: Use struct_size()

On Sat, May 06, 2023 at 06:22:06PM +0200, Christophe JAILLET wrote:
> Use struct_size() instead of hand writing it.
> This is less verbose and more informative.
> 
> 'mcf_chan' is now unused and can be removed. In fact, it is shadowed by
> another variable in the 'for' loop below. Keep this one.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
> ---
> It will also help scripts when __counted_by macro will be added.
> See [1].
> 
> [1]: https://lore.kernel.org/all/6453f739.170a0220.62695.7785@mx.google.com/

Of course, the main selling point of struct_size() for me is that it
protects you against integer overflows.  Open coding the math might end
up giving you a size which is smaller than expected but struct_size()
will give you ULONG_MAX in that same situation.  The allocation will
fail as expected.  #Safe.

Even when the open coded math is safe, this is easier to audit in an
automated way.

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ