check sb_set_blocksize/sb_min_blocksize returns
Subsystems (9)
PATCH 1/1 check sb_set_blocksize/sb_min_blocksize returns
This patch checks the success/failure (return value) of sb_set_blocksize() and sb_min_blocksize() calls in all filesystems (well, there were a couple of calls that I omitted since they looked safe).
Comments?
Thanks,
--
~Randy
description: check success/failure of sb_set_blocksize() and
sb_min_blocksize() calls in all filesystemsproduct_versions: Linux 2.6.0-test7patch_name: fs_setblocksize.patchpatch_version: 2003-10-16.22:14:47
author: Randy.Dunlap <[email protected]>
diffstat:=
fs/befs/linuxvfs.c | 11 +++++++++-- fs/bfs/inode.c | 7 ++++++- fs/ext3/super.c | 6 +++++- fs/fat/inode.c | 5 ++++- fs/hfs/super.c | 6 +++++- fs/hpfs/super.c | 6 +++++- fs/isofs/inode.c | 7 ++++++- fs/jfs/super.c | 8 +++++++- fs/qnx4/inode.c | 6 +++++- fs/reiserfs/super.c | 7 ++++++- fs/romfs/inode.c | 6 +++++- fs/sysv/super.c | 25 +++++++++++++++++++++---- fs/xfs/linux/xfs_super.c | 6 +++++- 13 files changed, 89 insertions(+), 17 deletions(-)
fs/xfs/linux/xfs_super.c renamed from fs/xfs/linux/xfs_super.c~setblocksize +5 -1
@@ -753,7 +753,11 @@ goto fail_vfsop; } -sb_min_blocksize (sb,BBSIZE ); +if (!sb_min_blocksize (sb,BBSIZE )) { +printk (KERN_ERR "XFS: unable to set min blocksize\n" ); +bhv_remove_all_vfsops (vfsp,1 ); + goto fail_vfsop; + } sb->s_export_op = &linvfs_export_ops; sb->s_qcop = &linvfs_qops; sb->s_op = &linvfs_sops;
fs/jfs/super.c renamed from fs/jfs/super.c~setblocksize +7 -1
@@ -325,13 +325,19 @@if (newLVSize) {printk (KERN_ERR "resize option for remount only\n" ); +kfree (sbi);return -EINVAL ; }/* * Initialize blocksize to 4K. */ -sb_set_blocksize (sb,PSIZE ); +if (!sb_set_blocksize (sb,PSIZE )) { +printk (KERN_ERR "JFS: device does not support %d byte blocks\n" , +PSIZE ); +kfree (sbi); +return -EINVAL ; + }/* * Set method vectors.
fs/hfs/super.c renamed from fs/hfs/super.c~setblocksize +5 -1
@@ -518,7 +518,11 @@ }/* set the device driver to 512-byte blocks */ -sb_set_blocksize (s,HFS_SECTOR_SIZE ); +if (!sb_set_blocksize (s,HFS_SECTOR_SIZE )) { +hfs_warn ("HFS: device does not support %d byte blocks\n" , +HFS_SECTOR_SIZE ); + goto bail2; + }#ifdef CONFIG_MAC_PARTITION /* check to see if we're in a partition */
fs/bfs/inode.c renamed from fs/bfs/inode.c~setblocksize +6 -1
@@ -303,7 +303,11 @@ s->s_fs_info = info;memset (info,0 ,sizeof (*info)); -sb_set_blocksize (s,BFS_BSIZE ); +if (!sb_set_blocksize (s,BFS_BSIZE )) { +printk (KERN_ERR "BFS: device does not support %d byte blocks\n" , +BFS_BSIZE ); + goto out2; + } bh =sb_bread (s,0 );if (!bh)
@@ -375,6 +379,7 @@ out:brelse (bh); +out2:kfree (info); s->s_fs_info =NULL ;return -EINVAL ;
fs/reiserfs/super.c renamed from fs/reiserfs/super.c~setblocksize +6 -1
@@ -961,7 +961,12 @@// // ok, reiserfs signature (old or new) found in at the given offset // -sb_set_blocksize (s,sb_blocksize (rs)); +if (!sb_set_blocksize (s,sb_blocksize (rs))) { +printk (KERN_ERR "sh-2006b: device does not support %d byte blocks\n" , +sb_blocksize (rs)); +brelse (bh); +return 1 ; + }brelse (bh); bh =sb_bread (s, offset / s->s_blocksize);
fs/befs/linuxvfs.c renamed from fs/befs/linuxvfs.c~setblocksize +9 -2
@@ -826,7 +826,10 @@* least 1k to get the second 512 bytes of the volume. * -WD 10-26-01 */ -sb_min_blocksize (sb,1024 ); +if (!sb_min_blocksize (sb,1024 )) { +befs_error (sb,"unable to set min blocksize" ); + goto unaquire_priv_sbp; + }if (!(bh =sb_bread (sb, sb_block))) {befs_error (sb,"unable to read superblock" );
@@ -860,7 +863,11 @@*/ sb->s_magic =BEFS_SUPER_MAGIC ;/* Set real blocksize of fs */ -sb_set_blocksize (sb, (ulong ) befs_sb->block_size); +if (!sb_set_blocksize (sb, (ulong ) befs_sb->block_size)) { +printk (KERN_ERR "BEFS: device does not support %d byte blocks\n" , + befs_sb->block_size); + goto unaquire_priv_sbp; + } sb->s_op = (struct super_operations *) &befs_sops; sb->s_root =d_alloc_root (iget (sb,iaddr2blockno (sb, &(befs_sb->root_dir))));
fs/sysv/super.c renamed from fs/sysv/super.c~setblocksize +21 -4
@@ -369,7 +369,11 @@ sbi->s_block_base =0 ; sb->s_fs_info = sbi; -sb_set_blocksize (sb,BLOCK_SIZE ); +if (!sb_set_blocksize (sb,BLOCK_SIZE )) { +printk (KERN_ERR "SystemV FS: device does not support %d byte blocks\n" , +BLOCK_SIZE ); + goto failed; + }for (i =0 ; i <sizeof (flavours)/sizeof (flavours[0 ]) && !size; i++) {brelse (bh);
@@ -386,7 +390,11 @@case 1 : blocknr = bh->b_blocknr <<1 ;brelse (bh); -sb_set_blocksize (sb,512 ); +if (!sb_set_blocksize (sb,512 )) { +printk (KERN_ERR "SystemV FS: device does not support %d byte blocks\n" , +512 ); + goto failed; + } bh1 =sb_bread (sb, blocknr); bh =sb_bread (sb, blocknr +1 );break ;
@@ -396,7 +404,11 @@case 3 : blocknr = bh->b_blocknr >>1 ;brelse (bh); -sb_set_blocksize (sb,2048 ); +if (!sb_set_blocksize (sb,2048 )) { +printk (KERN_ERR "SystemV FS: device does not support %d byte blocks\n" , +2048 ); + goto failed; + } bh1 = bh =sb_bread (sb, blocknr);break ;default :
@@ -455,7 +467,11 @@ sbi->s_bytesex =BYTESEX_PDP ; sb->s_fs_info = sbi; -sb_set_blocksize (sb,512 ); +if (!sb_set_blocksize (sb,512 )) { +printk (KERN_ERR "SystemV FS: device does not support %d byte blocks\n" , +512 ); + goto fail_sbi; + }if ((bh =sb_bread (sb,1 )) ==NULL ) {if (!silent)
@@ -490,6 +506,7 @@ failed:brelse (bh2);brelse (bh); +fail_sbi:kfree (sbi);return -EINVAL ; }
fs/hpfs/super.c renamed from fs/hpfs/super.c~setblocksize +5 -1
@@ -495,7 +495,11 @@ }/*sbi->sb_mounting = 1;*/ -sb_set_blocksize (s,512 ); +if (!sb_set_blocksize (s,512 )) { +printk (KERN_ERR "HPFS: device does not support %d byte blocks\n" , +512 ); + goto bail0; + } sbi->sb_fs_size =-1 ;if (!(bootblock =hpfs_map_sector (s,0 , &bh0,0 ))) goto bail1;if (!(superblock =hpfs_map_sector (s,16 , &bh1,1 ))) goto bail2;
fs/fat/inode.c renamed from fs/fat/inode.c~setblocksize +4 -1
@@ -791,7 +791,10 @@init_MUTEX (&sbi->fat_lock); error = -EIO ; -sb_min_blocksize (sb,512 ); +if (!sb_min_blocksize (sb,512 )) { +printk (KERN_ERR "FAT: unable to set min blocksize\n" ); + goto out_fail; + } bh =sb_bread (sb,0 );if (bh ==NULL ) {printk (KERN_ERR "FAT: unable to read boot sector\n" );
fs/ext3/super.c renamed from fs/ext3/super.c~setblocksize +5 -1
@@ -1169,7 +1169,11 @@ }brelse (bh); -sb_set_blocksize (sb, blocksize); +if (!sb_set_blocksize (sb, blocksize)) { +printk (KERN_ERR "EXT3-fs: device does not support %d byte blocks\n" , + blocksize); + goto failed_mount; + } logic_sb_block = (sb_block *EXT3_MIN_BLOCK_SIZE ) / blocksize; offset = (sb_block *EXT3_MIN_BLOCK_SIZE ) % blocksize; bh =sb_bread (sb, logic_sb_block);
fs/isofs/inode.c renamed from fs/isofs/inode.c~setblocksize +6 -1
@@ -791,7 +791,8 @@* entries. By forcing the blocksize in this way, we ensure * that we will never be required to do this. */ -sb_set_blocksize (s, orig_zonesize); +if (!sb_set_blocksize (s, orig_zonesize)) + goto out_bad_blocksize; sbi->s_nls_iocharset =NULL ;
@@ -904,6 +905,10 @@printk (KERN_WARNING "Bad logical zone size %ld\n" , sbi->s_log_zone_size); goto out_freebh; +out_bad_blocksize: +printk (KERN_ERR "ISOFS: device does not support %d byte blocks\n" , + orig_zonesize); + goto out_freesbi; out_bad_size:printk (KERN_WARNING "Logical zone size(%d) < hardware blocksize(%u)\n" , orig_zonesize, opt.blocksize);
fs/romfs/inode.c renamed from fs/romfs/inode.c~setblocksize +5 -1
@@ -119,7 +119,11 @@/* I would parse the options here, but there are none.. :) */ -sb_set_blocksize (s,ROMBSIZE ); +if (!sb_set_blocksize (s,ROMBSIZE )) { +printk (KERN_ERR "romfs: device does not support %d byte blocks\n" , +ROMBSIZE ); + goto outnobh; + } s->s_maxbytes =0xFFFFFFFF ; bh =sb_bread (s,0 );
fs/qnx4/inode.c renamed from fs/qnx4/inode.c~setblocksize +5 -1
@@ -357,7 +357,11 @@ s->s_fs_info = qs;memset (qs,0 ,sizeof (struct qnx4_sb_info )); -sb_set_blocksize (s,QNX4_BLOCK_SIZE ); +if (!sb_set_blocksize (s,QNX4_BLOCK_SIZE )) { +printk (KERN_ERR "qnx4: device does not support %d byte blocks\n" , +QNX4_BLOCK_SIZE ); + goto outnobh; + }/* Check the superblock signature. Since the qnx4 code is dangerous, we should leave as quickly as possible