mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH master] block: fix calling cdev_get_block_device with partitions
Date: Mon, 10 Oct 2022 09:14:57 +0200	[thread overview]
Message-ID: <20221010071457.GF986@pengutronix.de> (raw)
In-Reply-To: <20221010063834.2110400-1-a.fatoum@pengutronix.de>

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 <a.fatoum@pengutronix.de>
> ---
>  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 |



      reply	other threads:[~2022-10-10  7:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-10  6:38 Ahmad Fatoum
2022-10-10  7:14 ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221010071457.GF986@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox