Return-Path: Received: from mx2.suse.de ([195.135.220.15]:38236 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726213AbeHQMq6 (ORCPT ); Fri, 17 Aug 2018 08:46:58 -0400 Date: Fri, 17 Aug 2018 11:44:13 +0200 From: Jan Kara To: Eric Sandeen Cc: fsdevel , Jan Kara , Bryan Gurney Subject: Re: [PATCH] isofs: reject hardware sector size > 2048 bytes Message-ID: <20180817094413.GC26216@quack2.suse.cz> References: <23729d08-aeba-7375-ca65-7658faa908e8@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <23729d08-aeba-7375-ca65-7658faa908e8@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu 16-08-18 21:44:02, Eric Sandeen wrote: > The largest block size supported by isofs is ISOFS_BLOCK_SIZE (2048), but > isofs_fill_super calls sb_min_blocksize and sets the blocksize to the > device's logical block size if it's larger than what we ended up with after > option parsing. > > If for some reason we try to mount a hard 4k device as an isofs filesystem, > we'll set opt.blocksize to 4096, and when we try to read the superblock > we found via: > > block = iso_blknum << (ISOFS_BLOCK_BITS - s->s_blocksize_bits) > > with s_blocksize_bits greater than ISOFS_BLOCK_BITS, we'll have a negative > shift and the bread will fail somewhat cryptically: > > isofs_fill_super: bread failed, dev=sda, iso_blknum=17, block=-2147483648 > > It seems best to just catch and clearly reject mounts of such a device. > > Reported-by: Bryan Gurney > Signed-off-by: Eric Sandeen Thanks Eric, I'll take this patch through my tree for rc2. Honza > --- > > diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c > index ec3fba7d492f..488a9e7f8f66 100644 > --- a/fs/isofs/inode.c > +++ b/fs/isofs/inode.c > @@ -24,6 +24,7 @@ > #include > #include > #include > +#include > > #include "isofs.h" > #include "zisofs.h" > @@ -653,6 +654,12 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) > /* > * What if bugger tells us to go beyond page size? > */ > + if (bdev_logical_block_size(s->s_bdev) > 2048) { > + printk(KERN_WARNING > + "ISOFS: unsupported/invalid hardware sector size %d\n", > + bdev_logical_block_size(s->s_bdev)); > + goto out_freesbi; > + } > opt.blocksize = sb_min_blocksize(s, opt.blocksize); > > sbi->s_high_sierra = 0; /* default is iso9660 */ > -- Jan Kara SUSE Labs, CR