linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] isofs: reject hardware sector size > 2048 bytes
@ 2018-08-17  2:44 Eric Sandeen
  2018-08-17  9:44 ` Jan Kara
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Sandeen @ 2018-08-17  2:44 UTC (permalink / raw)
  To: fsdevel; +Cc: Jan Kara, Bryan Gurney

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 <bgurney@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

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 <linux/mpage.h>
 #include <linux/user_namespace.h>
 #include <linux/seq_file.h>
+#include <linux/blkdev.h>
 
 #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 */

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] isofs: reject hardware sector size > 2048 bytes
  2018-08-17  2:44 [PATCH] isofs: reject hardware sector size > 2048 bytes Eric Sandeen
@ 2018-08-17  9:44 ` Jan Kara
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2018-08-17  9:44 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: fsdevel, Jan Kara, Bryan Gurney

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 <bgurney@redhat.com>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

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 <linux/mpage.h>
>  #include <linux/user_namespace.h>
>  #include <linux/seq_file.h>
> +#include <linux/blkdev.h>
>  
>  #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 <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-17 12:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-17  2:44 [PATCH] isofs: reject hardware sector size > 2048 bytes Eric Sandeen
2018-08-17  9:44 ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).