Messages in this thread | | | Date | Wed, 29 Apr 2020 22:12:29 +0800 | From | Ming Lei <> | 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@android.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
| |