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: <9519dda9acd9db009dcb43102cc9b36943b35217.camel@gmail.com>
Date: Thu, 29 Feb 2024 16:29:43 +0100
From: Nuno Sá <noname.nuno@...il.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>, Vinod Koul
 <vkoul@...nel.org>, Linus Walleij <linus.walleij@...aro.org>, Jonathan
 Cameron <Jonathan.Cameron@...wei.com>, Mark Brown <broonie@...nel.org>,
 Kees Cook <keescook@...omium.org>, linux-arm-kernel@...ts.infradead.org, 
 dmaengine@...r.kernel.org, linux-kernel@...r.kernel.org, 
 linux-iio@...r.kernel.org, linux-spi@...r.kernel.org,
 netdev@...r.kernel.org,  linux-hardening@...r.kernel.org
Cc: Jonathan Cameron <jic23@...nel.org>, Lars-Peter Clausen
 <lars@...afoo.de>,  "David S. Miller" <davem@...emloft.net>, Eric Dumazet
 <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni
 <pabeni@...hat.com>, "Gustavo A. R. Silva" <gustavoars@...nel.org>, Nuno Sa
 <nuno.sa@...log.com>
Subject: Re: [PATCH v4 5/8] iio: core: Use new helpers from overflow.h in
 iio_device_alloc()

On Wed, 2024-02-28 at 22:41 +0200, Andy Shevchenko wrote:
> We have two new helpers struct_size_with_data() and struct_data_pointer()
> that we can utilize in iio_device_alloc(). Do it so.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> Reviewed-by: Nuno Sa <nuno.sa@...log.com>
> ---
>  drivers/iio/industrialio-core.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 1986b3386307..223013725e32 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -1644,7 +1644,7 @@ struct iio_dev *iio_device_alloc(struct device *parent,
> int sizeof_priv)
>  	size_t alloc_size;
>  
>  	if (sizeof_priv)
> -		alloc_size = ALIGN(alloc_size, IIO_DMA_MINALIGN) +
> sizeof_priv;
> +		alloc_size = struct_size_with_data(iio_dev_opaque,
> IIO_DMA_MINALIGN, sizeof_priv);
>  	else
>  		alloc_size = sizeof(struct iio_dev_opaque);
>  
> @@ -1655,8 +1655,7 @@ struct iio_dev *iio_device_alloc(struct device *parent,
> int sizeof_priv)
>  	indio_dev = &iio_dev_opaque->indio_dev;
>  
>  	if (sizeof_priv)
> -		indio_dev->priv = (char *)iio_dev_opaque +
> -			ALIGN(sizeof(struct iio_dev_opaque),
> IIO_DMA_MINALIGN);
> +		indio_dev->priv = struct_data_pointer(iio_dev_opaque,
> IIO_DMA_MINALIGN);

I'd +1 for implementing what Kees suggested in IIO. Only thing is (I think), we
need to move struct iio_dev indioo_dev to the end of struct iio_dev_opaque.

- Nuno Sá




Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ