diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-16 21:12:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-16 21:12:38 -0400 |
commit | 5d5c5dca9c2db027770e44c69a73ea7f3919dcfc (patch) | |
tree | 68a9673c5a56874f36dda62dd724e5509479d6c3 | |
parent | ecb2ecd9c241de16ebb31b7dc441dbbfc0f6006e (diff) | |
parent | 6c29c50fda25c2ac2ce45a9b042ff7e424aa8eac (diff) |
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull ext2, ext3, quota fixes from Jan Kara:
"Fix three regressions caused by user namespace conversions (ext2,
ext3, quota) and minor ext3 fix and cleanup."
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
quota: Silence warning about PRJQUOTA not being handled in need_print_warning()
ext3: fix return values on parse_options() failure
ext2: fix return values on parse_options() failure
ext3: ext3_bread usage audit
ext3: fix possible non-initialized variable on htree_dirblock_to_tree()
-rw-r--r-- | fs/ext2/super.c | 4 | ||||
-rw-r--r-- | fs/ext3/namei.c | 40 | ||||
-rw-r--r-- | fs/ext3/namei.h | 19 | ||||
-rw-r--r-- | fs/ext3/super.c | 4 | ||||
-rw-r--r-- | fs/quota/dquot.c | 2 |
5 files changed, 46 insertions, 23 deletions
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 6c205d0c565b..fa04d023177e 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -469,7 +469,7 @@ static int parse_options(char *options, struct super_block *sb) | |||
469 | uid = make_kuid(current_user_ns(), option); | 469 | uid = make_kuid(current_user_ns(), option); |
470 | if (!uid_valid(uid)) { | 470 | if (!uid_valid(uid)) { |
471 | ext2_msg(sb, KERN_ERR, "Invalid uid value %d", option); | 471 | ext2_msg(sb, KERN_ERR, "Invalid uid value %d", option); |
472 | return -1; | 472 | return 0; |
473 | 473 | ||
474 | } | 474 | } |
475 | sbi->s_resuid = uid; | 475 | sbi->s_resuid = uid; |
@@ -480,7 +480,7 @@ static int parse_options(char *options, struct super_block *sb) | |||
480 | gid = make_kgid(current_user_ns(), option); | 480 | gid = make_kgid(current_user_ns(), option); |
481 | if (!gid_valid(gid)) { | 481 | if (!gid_valid(gid)) { |
482 | ext2_msg(sb, KERN_ERR, "Invalid gid value %d", option); | 482 | ext2_msg(sb, KERN_ERR, "Invalid gid value %d", option); |
483 | return -1; | 483 | return 0; |
484 | } | 484 | } |
485 | sbi->s_resgid = gid; | 485 | sbi->s_resgid = gid; |
486 | break; | 486 | break; |
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 8f4fddac01a6..890b8947c546 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c | |||
@@ -46,8 +46,7 @@ static struct buffer_head *ext3_append(handle_t *handle, | |||
46 | 46 | ||
47 | *block = inode->i_size >> inode->i_sb->s_blocksize_bits; | 47 | *block = inode->i_size >> inode->i_sb->s_blocksize_bits; |
48 | 48 | ||
49 | bh = ext3_bread(handle, inode, *block, 1, err); | 49 | if ((bh = ext3_dir_bread(handle, inode, *block, 1, err))) { |
50 | if (bh) { | ||
51 | inode->i_size += inode->i_sb->s_blocksize; | 50 | inode->i_size += inode->i_sb->s_blocksize; |
52 | EXT3_I(inode)->i_disksize = inode->i_size; | 51 | EXT3_I(inode)->i_disksize = inode->i_size; |
53 | *err = ext3_journal_get_write_access(handle, bh); | 52 | *err = ext3_journal_get_write_access(handle, bh); |
@@ -339,8 +338,10 @@ dx_probe(struct qstr *entry, struct inode *dir, | |||
339 | u32 hash; | 338 | u32 hash; |
340 | 339 | ||
341 | frame->bh = NULL; | 340 | frame->bh = NULL; |
342 | if (!(bh = ext3_bread (NULL,dir, 0, 0, err))) | 341 | if (!(bh = ext3_dir_bread(NULL, dir, 0, 0, err))) { |
342 | *err = ERR_BAD_DX_DIR; | ||
343 | goto fail; | 343 | goto fail; |
344 | } | ||
344 | root = (struct dx_root *) bh->b_data; | 345 | root = (struct dx_root *) bh->b_data; |
345 | if (root->info.hash_version != DX_HASH_TEA && | 346 | if (root->info.hash_version != DX_HASH_TEA && |
346 | root->info.hash_version != DX_HASH_HALF_MD4 && | 347 | root->info.hash_version != DX_HASH_HALF_MD4 && |
@@ -436,8 +437,10 @@ dx_probe(struct qstr *entry, struct inode *dir, | |||
436 | frame->entries = entries; | 437 | frame->entries = entries; |
437 | frame->at = at; | 438 | frame->at = at; |
438 | if (!indirect--) return frame; | 439 | if (!indirect--) return frame; |
439 | if (!(bh = ext3_bread (NULL,dir, dx_get_block(at), 0, err))) | 440 | if (!(bh = ext3_dir_bread(NULL, dir, dx_get_block(at), 0, err))) { |
441 | *err = ERR_BAD_DX_DIR; | ||
440 | goto fail2; | 442 | goto fail2; |
443 | } | ||
441 | at = entries = ((struct dx_node *) bh->b_data)->entries; | 444 | at = entries = ((struct dx_node *) bh->b_data)->entries; |
442 | if (dx_get_limit(entries) != dx_node_limit (dir)) { | 445 | if (dx_get_limit(entries) != dx_node_limit (dir)) { |
443 | ext3_warning(dir->i_sb, __func__, | 446 | ext3_warning(dir->i_sb, __func__, |
@@ -535,8 +538,8 @@ static int ext3_htree_next_block(struct inode *dir, __u32 hash, | |||
535 | * block so no check is necessary | 538 | * block so no check is necessary |
536 | */ | 539 | */ |
537 | while (num_frames--) { | 540 | while (num_frames--) { |
538 | if (!(bh = ext3_bread(NULL, dir, dx_get_block(p->at), | 541 | if (!(bh = ext3_dir_bread(NULL, dir, dx_get_block(p->at), |
539 | 0, &err))) | 542 | 0, &err))) |
540 | return err; /* Failure */ | 543 | return err; /* Failure */ |
541 | p++; | 544 | p++; |
542 | brelse (p->bh); | 545 | brelse (p->bh); |
@@ -559,10 +562,11 @@ static int htree_dirblock_to_tree(struct file *dir_file, | |||
559 | { | 562 | { |
560 | struct buffer_head *bh; | 563 | struct buffer_head *bh; |
561 | struct ext3_dir_entry_2 *de, *top; | 564 | struct ext3_dir_entry_2 *de, *top; |
562 | int err, count = 0; | 565 | int err = 0, count = 0; |
563 | 566 | ||
564 | dxtrace(printk("In htree dirblock_to_tree: block %d\n", block)); | 567 | dxtrace(printk("In htree dirblock_to_tree: block %d\n", block)); |
565 | if (!(bh = ext3_bread (NULL, dir, block, 0, &err))) | 568 | |
569 | if (!(bh = ext3_dir_bread(NULL, dir, block, 0, &err))) | ||
566 | return err; | 570 | return err; |
567 | 571 | ||
568 | de = (struct ext3_dir_entry_2 *) bh->b_data; | 572 | de = (struct ext3_dir_entry_2 *) bh->b_data; |
@@ -976,7 +980,7 @@ static struct buffer_head * ext3_dx_find_entry(struct inode *dir, | |||
976 | return NULL; | 980 | return NULL; |
977 | do { | 981 | do { |
978 | block = dx_get_block(frame->at); | 982 | block = dx_get_block(frame->at); |
979 | if (!(bh = ext3_bread (NULL,dir, block, 0, err))) | 983 | if (!(bh = ext3_dir_bread (NULL, dir, block, 0, err))) |
980 | goto errout; | 984 | goto errout; |
981 | 985 | ||
982 | retval = search_dirblock(bh, dir, entry, | 986 | retval = search_dirblock(bh, dir, entry, |
@@ -1458,9 +1462,9 @@ static int ext3_add_entry (handle_t *handle, struct dentry *dentry, | |||
1458 | } | 1462 | } |
1459 | blocks = dir->i_size >> sb->s_blocksize_bits; | 1463 | blocks = dir->i_size >> sb->s_blocksize_bits; |
1460 | for (block = 0; block < blocks; block++) { | 1464 | for (block = 0; block < blocks; block++) { |
1461 | bh = ext3_bread(handle, dir, block, 0, &retval); | 1465 | if (!(bh = ext3_dir_bread(handle, dir, block, 0, &retval))) |
1462 | if(!bh) | ||
1463 | return retval; | 1466 | return retval; |
1467 | |||
1464 | retval = add_dirent_to_buf(handle, dentry, inode, NULL, bh); | 1468 | retval = add_dirent_to_buf(handle, dentry, inode, NULL, bh); |
1465 | if (retval != -ENOSPC) | 1469 | if (retval != -ENOSPC) |
1466 | return retval; | 1470 | return retval; |
@@ -1500,7 +1504,7 @@ static int ext3_dx_add_entry(handle_t *handle, struct dentry *dentry, | |||
1500 | entries = frame->entries; | 1504 | entries = frame->entries; |
1501 | at = frame->at; | 1505 | at = frame->at; |
1502 | 1506 | ||
1503 | if (!(bh = ext3_bread(handle,dir, dx_get_block(frame->at), 0, &err))) | 1507 | if (!(bh = ext3_dir_bread(handle, dir, dx_get_block(frame->at), 0, &err))) |
1504 | goto cleanup; | 1508 | goto cleanup; |
1505 | 1509 | ||
1506 | BUFFER_TRACE(bh, "get_write_access"); | 1510 | BUFFER_TRACE(bh, "get_write_access"); |
@@ -1790,8 +1794,7 @@ retry: | |||
1790 | inode->i_op = &ext3_dir_inode_operations; | 1794 | inode->i_op = &ext3_dir_inode_operations; |
1791 | inode->i_fop = &ext3_dir_operations; | 1795 | inode->i_fop = &ext3_dir_operations; |
1792 | inode->i_size = EXT3_I(inode)->i_disksize = inode->i_sb->s_blocksize; | 1796 | inode->i_size = EXT3_I(inode)->i_disksize = inode->i_sb->s_blocksize; |
1793 | dir_block = ext3_bread (handle, inode, 0, 1, &err); | 1797 | if (!(dir_block = ext3_dir_bread(handle, inode, 0, 1, &err))) |
1794 | if (!dir_block) | ||
1795 | goto out_clear_inode; | 1798 | goto out_clear_inode; |
1796 | 1799 | ||
1797 | BUFFER_TRACE(dir_block, "get_write_access"); | 1800 | BUFFER_TRACE(dir_block, "get_write_access"); |
@@ -1859,7 +1862,7 @@ static int empty_dir (struct inode * inode) | |||
1859 | 1862 | ||
1860 | sb = inode->i_sb; | 1863 | sb = inode->i_sb; |
1861 | if (inode->i_size < EXT3_DIR_REC_LEN(1) + EXT3_DIR_REC_LEN(2) || | 1864 | if (inode->i_size < EXT3_DIR_REC_LEN(1) + EXT3_DIR_REC_LEN(2) || |
1862 | !(bh = ext3_bread (NULL, inode, 0, 0, &err))) { | 1865 | !(bh = ext3_dir_bread(NULL, inode, 0, 0, &err))) { |
1863 | if (err) | 1866 | if (err) |
1864 | ext3_error(inode->i_sb, __func__, | 1867 | ext3_error(inode->i_sb, __func__, |
1865 | "error %d reading directory #%lu offset 0", | 1868 | "error %d reading directory #%lu offset 0", |
@@ -1890,9 +1893,8 @@ static int empty_dir (struct inode * inode) | |||
1890 | (void *) de >= (void *) (bh->b_data+sb->s_blocksize)) { | 1893 | (void *) de >= (void *) (bh->b_data+sb->s_blocksize)) { |
1891 | err = 0; | 1894 | err = 0; |
1892 | brelse (bh); | 1895 | brelse (bh); |
1893 | bh = ext3_bread (NULL, inode, | 1896 | if (!(bh = ext3_dir_bread (NULL, inode, |
1894 | offset >> EXT3_BLOCK_SIZE_BITS(sb), 0, &err); | 1897 | offset >> EXT3_BLOCK_SIZE_BITS(sb), 0, &err))) { |
1895 | if (!bh) { | ||
1896 | if (err) | 1898 | if (err) |
1897 | ext3_error(sb, __func__, | 1899 | ext3_error(sb, __func__, |
1898 | "error %d reading directory" | 1900 | "error %d reading directory" |
@@ -2388,7 +2390,7 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry, | |||
2388 | goto end_rename; | 2390 | goto end_rename; |
2389 | } | 2391 | } |
2390 | retval = -EIO; | 2392 | retval = -EIO; |
2391 | dir_bh = ext3_bread (handle, old_inode, 0, 0, &retval); | 2393 | dir_bh = ext3_dir_bread(handle, old_inode, 0, 0, &retval); |
2392 | if (!dir_bh) | 2394 | if (!dir_bh) |
2393 | goto end_rename; | 2395 | goto end_rename; |
2394 | if (le32_to_cpu(PARENT_INO(dir_bh->b_data)) != old_dir->i_ino) | 2396 | if (le32_to_cpu(PARENT_INO(dir_bh->b_data)) != old_dir->i_ino) |
diff --git a/fs/ext3/namei.h b/fs/ext3/namei.h index f2ce2b0065c9..46304d8c9f0a 100644 --- a/fs/ext3/namei.h +++ b/fs/ext3/namei.h | |||
@@ -6,3 +6,22 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | extern struct dentry *ext3_get_parent(struct dentry *child); | 8 | extern struct dentry *ext3_get_parent(struct dentry *child); |
9 | |||
10 | static inline struct buffer_head *ext3_dir_bread(handle_t *handle, | ||
11 | struct inode *inode, | ||
12 | int block, int create, | ||
13 | int *err) | ||
14 | { | ||
15 | struct buffer_head *bh; | ||
16 | |||
17 | bh = ext3_bread(handle, inode, block, create, err); | ||
18 | |||
19 | if (!bh && !(*err)) { | ||
20 | *err = -EIO; | ||
21 | ext3_error(inode->i_sb, __func__, | ||
22 | "Directory hole detected on inode %lu\n", | ||
23 | inode->i_ino); | ||
24 | return NULL; | ||
25 | } | ||
26 | return bh; | ||
27 | } | ||
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 29e79713c7eb..5366393528df 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c | |||
@@ -1001,7 +1001,7 @@ static int parse_options (char *options, struct super_block *sb, | |||
1001 | uid = make_kuid(current_user_ns(), option); | 1001 | uid = make_kuid(current_user_ns(), option); |
1002 | if (!uid_valid(uid)) { | 1002 | if (!uid_valid(uid)) { |
1003 | ext3_msg(sb, KERN_ERR, "Invalid uid value %d", option); | 1003 | ext3_msg(sb, KERN_ERR, "Invalid uid value %d", option); |
1004 | return -1; | 1004 | return 0; |
1005 | 1005 | ||
1006 | } | 1006 | } |
1007 | sbi->s_resuid = uid; | 1007 | sbi->s_resuid = uid; |
@@ -1012,7 +1012,7 @@ static int parse_options (char *options, struct super_block *sb, | |||
1012 | gid = make_kgid(current_user_ns(), option); | 1012 | gid = make_kgid(current_user_ns(), option); |
1013 | if (!gid_valid(gid)) { | 1013 | if (!gid_valid(gid)) { |
1014 | ext3_msg(sb, KERN_ERR, "Invalid gid value %d", option); | 1014 | ext3_msg(sb, KERN_ERR, "Invalid gid value %d", option); |
1015 | return -1; | 1015 | return 0; |
1016 | } | 1016 | } |
1017 | sbi->s_resgid = gid; | 1017 | sbi->s_resgid = gid; |
1018 | break; | 1018 | break; |
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 557a9c20a215..05ae3c97f7a5 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
@@ -1160,6 +1160,8 @@ static int need_print_warning(struct dquot_warn *warn) | |||
1160 | return uid_eq(current_fsuid(), warn->w_dq_id.uid); | 1160 | return uid_eq(current_fsuid(), warn->w_dq_id.uid); |
1161 | case GRPQUOTA: | 1161 | case GRPQUOTA: |
1162 | return in_group_p(warn->w_dq_id.gid); | 1162 | return in_group_p(warn->w_dq_id.gid); |
1163 | case PRJQUOTA: /* Never taken... Just make gcc happy */ | ||
1164 | return 0; | ||
1163 | } | 1165 | } |
1164 | return 0; | 1166 | return 0; |
1165 | } | 1167 | } |