[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200429141229.GE700644@T590>
Date: Wed, 29 Apr 2020 22:12:29 +0800
From: Ming Lei <ming.lei@...hat.com>
To: Martijn Coenen <maco@...roid.com>
Cc: axboe@...nel.dk, hch@....de, narayan@...gle.com,
zezeozue@...gle.com, kernel-team@...roid.com, maco@...gle.com,
bvanassche@....org, Chaitanya.Kulkarni@....com, jaegeuk@...nel.org,
linux-block@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 01/10] loop: Factor out loop size validation
On Wed, Apr 29, 2020 at 04:03:32PM +0200, Martijn Coenen wrote:
> Ensuring we don't truncate loff_t when casting to sector_t is done in
> multiple places; factor it out.
>
> Signed-off-by: Martijn Coenen <maco@...roid.com>
> ---
> drivers/block/loop.c | 25 ++++++++++++++++++++-----
> 1 file changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index f1754262fc94..396b8bd4d75c 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -228,15 +228,30 @@ static void __loop_update_dio(struct loop_device *lo, bool dio)
> blk_mq_unfreeze_queue(lo->lo_queue);
> }
>
> +/**
> + * loop_validate_size() - validates that the passed in size fits in a sector_t
> + * @size: size to validate
> + */
> +static int
> +loop_validate_size(loff_t size)
> +{
> + if ((loff_t)(sector_t)size != size)
> + return -EFBIG;
> +
> + return 0;
> +}
> +
Now sector_t has been switched to u64 unconditionally, do we still need such
validation?
Thanks,
Ming
Powered by blists - more mailing lists