On Mon, Oct 10, 2022 at 08:38:34AM +0200, Ahmad Fatoum wrote:
> For partitions, cdev->priv references the parent block device.
> Doing the pointer arithmetic in container_of will result in an
> out-of-bounds access. Do what the rest of the code does
> and access cdev->priv instead.
>
> Fixes: 84173bf3d0cc ("block: set S_IFBLK for block devices instead of
> S_IFCHR")
> Signed-off-by: Ahmad Fatoum <[email protected]>
> ---
> common/block.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks
Sascha
>
> diff --git a/common/block.c b/common/block.c
> index 19bb81df2c3d..a4cfd6e22771 100644
> --- a/common/block.c
> +++ b/common/block.c
> @@ -366,7 +366,7 @@ struct block_device *cdev_get_block_device(struct cdev
> *cdev)
> if (!cdev || cdev->ops != &block_ops)
> return NULL;
>
> - return container_of(cdev, struct block_device, cdev);
> + return cdev->priv;
> }
>
> int blockdevice_register(struct block_device *blk)
> --
> 2.30.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |