Skip to content

Commit 08d9329

Browse files
committed
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull misc udf, ext2, ext3, and isofs fixes from Jan Kara: "Assorted, mostly trivial, fixes for udf, ext2, ext3, and isofs. I'm on vacation and scarcely checking email since we are expecting baby any day now but these fixes should be safe to go in and I don't want to delay them unnecessarily." * 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: udf: avoid info leak on export isofs: avoid info leak on export udf: Improve table length check to avoid possible overflow ext3: Check return value of blkdev_issue_flush() jbd: Check return value of blkdev_issue_flush() udf: Do not decrement i_blocks when freeing indirect extent block udf: Fix memory leak when mounting ext2: cleanup the confused goto label UDF: Remove unnecessary variable "offset" from udf_fill_inode udf: stop using s_dirt ext3: force ro mount if ext3_setup_super() fails quota: fix checkpatch.pl warning by replacing <asm/uaccess.h> with <linux/uaccess.h>
2 parents 2c05b2c + 0143fc5 commit 08d9329

12 files changed

Lines changed: 88 additions & 82 deletions

File tree

‎fs/ext2/super.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -771,13 +771,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
771771
err = -ENOMEM;
772772
sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
773773
if (!sbi)
774-
goto failed_unlock;
774+
goto failed;
775775

776776
sbi->s_blockgroup_lock =
777777
kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL);
778778
if (!sbi->s_blockgroup_lock) {
779779
kfree(sbi);
780-
goto failed_unlock;
780+
goto failed;
781781
}
782782
sb->s_fs_info = sbi;
783783
sbi->s_sb_block = sb_block;
@@ -1130,7 +1130,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
11301130
sb->s_fs_info = NULL;
11311131
kfree(sbi->s_blockgroup_lock);
11321132
kfree(sbi);
1133-
failed_unlock:
1133+
failed:
11341134
return ret;
11351135
}
11361136

‎fs/ext3/fsync.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,13 @@ int ext3_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
9292
* disk caches manually so that data really is on persistent
9393
* storage
9494
*/
95-
if (needs_barrier)
96-
blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
95+
if (needs_barrier) {
96+
int err;
97+
98+
err = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
99+
if (!ret)
100+
ret = err;
101+
}
97102
out:
98103
trace_ext3_sync_file_exit(inode, ret);
99104
return ret;

‎fs/ext3/super.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2058,7 +2058,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
20582058
goto failed_mount3;
20592059
}
20602060

2061-
ext3_setup_super (sb, es, sb->s_flags & MS_RDONLY);
2061+
if (ext3_setup_super(sb, es, sb->s_flags & MS_RDONLY))
2062+
sb->s_flags |= MS_RDONLY;
20622063

20632064
EXT3_SB(sb)->s_mount_state |= EXT3_ORPHAN_FS;
20642065
ext3_orphan_cleanup(sb, es);

‎fs/isofs/export.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ isofs_export_encode_fh(struct inode *inode,
134134
len = 3;
135135
fh32[0] = ei->i_iget5_block;
136136
fh16[2] = (__u16)ei->i_iget5_offset; /* fh16 [sic] */
137+
fh16[3] = 0; /* avoid leaking uninitialized data */
137138
fh32[2] = inode->i_generation;
138139
if (parent) {
139140
struct iso_inode_info *eparent;

‎fs/jbd/recovery.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,11 @@ int journal_recover(journal_t *journal)
265265
if (!err)
266266
err = err2;
267267
/* Flush disk caches to get replayed data on the permanent storage */
268-
if (journal->j_flags & JFS_BARRIER)
269-
blkdev_issue_flush(journal->j_fs_dev, GFP_KERNEL, NULL);
268+
if (journal->j_flags & JFS_BARRIER) {
269+
err2 = blkdev_issue_flush(journal->j_fs_dev, GFP_KERNEL, NULL);
270+
if (!err)
271+
err = err2;
272+
}
270273

271274
return err;
272275
}

‎fs/quota/dquot.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
#include <linux/quotaops.h>
7979
#include "../internal.h" /* ugh */
8080

81-
#include <asm/uaccess.h>
81+
#include <linux/uaccess.h>
8282

8383
/*
8484
* There are three quota SMP locks. dq_list_lock protects all lists with quotas

‎fs/quota/quota.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <linux/namei.h>
1010
#include <linux/slab.h>
1111
#include <asm/current.h>
12-
#include <asm/uaccess.h>
12+
#include <linux/uaccess.h>
1313
#include <linux/kernel.h>
1414
#include <linux/security.h>
1515
#include <linux/syscalls.h>

‎fs/udf/inode.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,6 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
12471247
{
12481248
struct fileEntry *fe;
12491249
struct extendedFileEntry *efe;
1250-
int offset;
12511250
struct udf_sb_info *sbi = UDF_SB(inode->i_sb);
12521251
struct udf_inode_info *iinfo = UDF_I(inode);
12531252
unsigned int link_count;
@@ -1359,7 +1358,6 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
13591358
iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr);
13601359
iinfo->i_lenAlloc = le32_to_cpu(fe->lengthAllocDescs);
13611360
iinfo->i_checkpoint = le32_to_cpu(fe->checkpoint);
1362-
offset = sizeof(struct fileEntry) + iinfo->i_lenEAttr;
13631361
} else {
13641362
inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) <<
13651363
(inode->i_sb->s_blocksize_bits - 9);
@@ -1381,8 +1379,6 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
13811379
iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr);
13821380
iinfo->i_lenAlloc = le32_to_cpu(efe->lengthAllocDescs);
13831381
iinfo->i_checkpoint = le32_to_cpu(efe->checkpoint);
1384-
offset = sizeof(struct extendedFileEntry) +
1385-
iinfo->i_lenEAttr;
13861382
}
13871383

13881384
switch (fe->icbTag.fileType) {

‎fs/udf/namei.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,7 @@ static int udf_encode_fh(struct inode *inode, __u32 *fh, int *lenp,
12791279
*lenp = 3;
12801280
fid->udf.block = location.logicalBlockNum;
12811281
fid->udf.partref = location.partitionReferenceNum;
1282+
fid->udf.parent_partref = 0;
12821283
fid->udf.generation = inode->i_generation;
12831284

12841285
if (parent) {

‎fs/udf/super.c‎

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,63 @@ static int udf_sb_alloc_partition_maps(struct super_block *sb, u32 count)
252252
return 0;
253253
}
254254

255+
static void udf_sb_free_bitmap(struct udf_bitmap *bitmap)
256+
{
257+
int i;
258+
int nr_groups = bitmap->s_nr_groups;
259+
int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) *
260+
nr_groups);
261+
262+
for (i = 0; i < nr_groups; i++)
263+
if (bitmap->s_block_bitmap[i])
264+
brelse(bitmap->s_block_bitmap[i]);
265+
266+
if (size <= PAGE_SIZE)
267+
kfree(bitmap);
268+
else
269+
vfree(bitmap);
270+
}
271+
272+
static void udf_free_partition(struct udf_part_map *map)
273+
{
274+
int i;
275+
struct udf_meta_data *mdata;
276+
277+
if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE)
278+
iput(map->s_uspace.s_table);
279+
if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
280+
iput(map->s_fspace.s_table);
281+
if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP)
282+
udf_sb_free_bitmap(map->s_uspace.s_bitmap);
283+
if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
284+
udf_sb_free_bitmap(map->s_fspace.s_bitmap);
285+
if (map->s_partition_type == UDF_SPARABLE_MAP15)
286+
for (i = 0; i < 4; i++)
287+
brelse(map->s_type_specific.s_sparing.s_spar_map[i]);
288+
else if (map->s_partition_type == UDF_METADATA_MAP25) {
289+
mdata = &map->s_type_specific.s_metadata;
290+
iput(mdata->s_metadata_fe);
291+
mdata->s_metadata_fe = NULL;
292+
293+
iput(mdata->s_mirror_fe);
294+
mdata->s_mirror_fe = NULL;
295+
296+
iput(mdata->s_bitmap_fe);
297+
mdata->s_bitmap_fe = NULL;
298+
}
299+
}
300+
301+
static void udf_sb_free_partitions(struct super_block *sb)
302+
{
303+
struct udf_sb_info *sbi = UDF_SB(sb);
304+
int i;
305+
306+
for (i = 0; i < sbi->s_partitions; i++)
307+
udf_free_partition(&sbi->s_partmaps[i]);
308+
kfree(sbi->s_partmaps);
309+
sbi->s_partmaps = NULL;
310+
}
311+
255312
static int udf_show_options(struct seq_file *seq, struct dentry *root)
256313
{
257314
struct super_block *sb = root->d_sb;
@@ -1283,7 +1340,7 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,
12831340
BUG_ON(ident != TAG_IDENT_LVD);
12841341
lvd = (struct logicalVolDesc *)bh->b_data;
12851342
table_len = le32_to_cpu(lvd->mapTableLength);
1286-
if (sizeof(*lvd) + table_len > sb->s_blocksize) {
1343+
if (table_len > sb->s_blocksize - sizeof(*lvd)) {
12871344
udf_err(sb, "error loading logical volume descriptor: "
12881345
"Partition table too long (%u > %lu)\n", table_len,
12891346
sb->s_blocksize - sizeof(*lvd));
@@ -1596,7 +1653,11 @@ static int udf_load_sequence(struct super_block *sb, struct buffer_head *bh,
15961653
/* responsible for finding the PartitionDesc(s) */
15971654
if (!udf_process_sequence(sb, main_s, main_e, fileset))
15981655
return 1;
1599-
return !udf_process_sequence(sb, reserve_s, reserve_e, fileset);
1656+
udf_sb_free_partitions(sb);
1657+
if (!udf_process_sequence(sb, reserve_s, reserve_e, fileset))
1658+
return 1;
1659+
udf_sb_free_partitions(sb);
1660+
return 0;
16001661
}
16011662

16021663
/*
@@ -1861,55 +1922,8 @@ u64 lvid_get_unique_id(struct super_block *sb)
18611922
return ret;
18621923
}
18631924

1864-
static void udf_sb_free_bitmap(struct udf_bitmap *bitmap)
1865-
{
1866-
int i;
1867-
int nr_groups = bitmap->s_nr_groups;
1868-
int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) *
1869-
nr_groups);
1870-
1871-
for (i = 0; i < nr_groups; i++)
1872-
if (bitmap->s_block_bitmap[i])
1873-
brelse(bitmap->s_block_bitmap[i]);
1874-
1875-
if (size <= PAGE_SIZE)
1876-
kfree(bitmap);
1877-
else
1878-
vfree(bitmap);
1879-
}
1880-
1881-
static void udf_free_partition(struct udf_part_map *map)
1882-
{
1883-
int i;
1884-
struct udf_meta_data *mdata;
1885-
1886-
if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_TABLE)
1887-
iput(map->s_uspace.s_table);
1888-
if (map->s_partition_flags & UDF_PART_FLAG_FREED_TABLE)
1889-
iput(map->s_fspace.s_table);
1890-
if (map->s_partition_flags & UDF_PART_FLAG_UNALLOC_BITMAP)
1891-
udf_sb_free_bitmap(map->s_uspace.s_bitmap);
1892-
if (map->s_partition_flags & UDF_PART_FLAG_FREED_BITMAP)
1893-
udf_sb_free_bitmap(map->s_fspace.s_bitmap);
1894-
if (map->s_partition_type == UDF_SPARABLE_MAP15)
1895-
for (i = 0; i < 4; i++)
1896-
brelse(map->s_type_specific.s_sparing.s_spar_map[i]);
1897-
else if (map->s_partition_type == UDF_METADATA_MAP25) {
1898-
mdata = &map->s_type_specific.s_metadata;
1899-
iput(mdata->s_metadata_fe);
1900-
mdata->s_metadata_fe = NULL;
1901-
1902-
iput(mdata->s_mirror_fe);
1903-
mdata->s_mirror_fe = NULL;
1904-
1905-
iput(mdata->s_bitmap_fe);
1906-
mdata->s_bitmap_fe = NULL;
1907-
}
1908-
}
1909-
19101925
static int udf_fill_super(struct super_block *sb, void *options, int silent)
19111926
{
1912-
int i;
19131927
int ret;
19141928
struct inode *inode = NULL;
19151929
struct udf_options uopt;
@@ -1974,7 +1988,6 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
19741988
sb->s_op = &udf_sb_ops;
19751989
sb->s_export_op = &udf_export_ops;
19761990

1977-
sb->s_dirt = 0;
19781991
sb->s_magic = UDF_SUPER_MAGIC;
19791992
sb->s_time_gran = 1000;
19801993

@@ -2072,18 +2085,14 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
20722085
error_out:
20732086
if (sbi->s_vat_inode)
20742087
iput(sbi->s_vat_inode);
2075-
if (sbi->s_partitions)
2076-
for (i = 0; i < sbi->s_partitions; i++)
2077-
udf_free_partition(&sbi->s_partmaps[i]);
20782088
#ifdef CONFIG_UDF_NLS
20792089
if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
20802090
unload_nls(sbi->s_nls_map);
20812091
#endif
20822092
if (!(sb->s_flags & MS_RDONLY))
20832093
udf_close_lvid(sb);
20842094
brelse(sbi->s_lvid_bh);
2085-
2086-
kfree(sbi->s_partmaps);
2095+
udf_sb_free_partitions(sb);
20872096
kfree(sbi);
20882097
sb->s_fs_info = NULL;
20892098

@@ -2096,10 +2105,6 @@ void _udf_err(struct super_block *sb, const char *function,
20962105
struct va_format vaf;
20972106
va_list args;
20982107

2099-
/* mark sb error */
2100-
if (!(sb->s_flags & MS_RDONLY))
2101-
sb->s_dirt = 1;
2102-
21032108
va_start(args, fmt);
21042109

21052110
vaf.fmt = fmt;
@@ -2128,24 +2133,20 @@ void _udf_warn(struct super_block *sb, const char *function,
21282133

21292134
static void udf_put_super(struct super_block *sb)
21302135
{
2131-
int i;
21322136
struct udf_sb_info *sbi;
21332137

21342138
sbi = UDF_SB(sb);
21352139

21362140
if (sbi->s_vat_inode)
21372141
iput(sbi->s_vat_inode);
2138-
if (sbi->s_partitions)
2139-
for (i = 0; i < sbi->s_partitions; i++)
2140-
udf_free_partition(&sbi->s_partmaps[i]);
21412142
#ifdef CONFIG_UDF_NLS
21422143
if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
21432144
unload_nls(sbi->s_nls_map);
21442145
#endif
21452146
if (!(sb->s_flags & MS_RDONLY))
21462147
udf_close_lvid(sb);
21472148
brelse(sbi->s_lvid_bh);
2148-
kfree(sbi->s_partmaps);
2149+
udf_sb_free_partitions(sb);
21492150
kfree(sb->s_fs_info);
21502151
sb->s_fs_info = NULL;
21512152
}
@@ -2161,7 +2162,6 @@ static int udf_sync_fs(struct super_block *sb, int wait)
21612162
* the buffer for IO
21622163
*/
21632164
mark_buffer_dirty(sbi->s_lvid_bh);
2164-
sb->s_dirt = 0;
21652165
sbi->s_lvid_dirty = 0;
21662166
}
21672167
mutex_unlock(&sbi->s_alloc_mutex);

0 commit comments

Comments
 (0)