aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-log.c
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2011-03-16 16:47:17 -0400
committerJosef Bacik <josef@redhat.com>2011-03-17 14:21:41 -0400
commit22a94d44bd6876a90630338229da6c0436d46593 (patch)
tree50e5c7dd52ccf9292240de995e5b42b1619bcd82 /fs/btrfs/tree-log.c
parent41415730a1050499fbd63b3f7dd59b3a4c3bb91a (diff)
Btrfs: add checks to verify dir items are correct
We need to make sure the dir items we get are valid dir items. So any time we try and read one check it with verify_dir_item, which will do various sanity checks to make sure it looks sane. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r--fs/btrfs/tree-log.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index a4bbb854dfd2..429cfcfadf90 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -1286,6 +1286,8 @@ static noinline int replay_one_dir_item(struct btrfs_trans_handle *trans,
1286 ptr_end = ptr + item_size; 1286 ptr_end = ptr + item_size;
1287 while (ptr < ptr_end) { 1287 while (ptr < ptr_end) {
1288 di = (struct btrfs_dir_item *)ptr; 1288 di = (struct btrfs_dir_item *)ptr;
1289 if (verify_dir_item(root, eb, di))
1290 return -EIO;
1289 name_len = btrfs_dir_name_len(eb, di); 1291 name_len = btrfs_dir_name_len(eb, di);
1290 ret = replay_one_name(trans, root, path, eb, di, key); 1292 ret = replay_one_name(trans, root, path, eb, di, key);
1291 BUG_ON(ret); 1293 BUG_ON(ret);
@@ -1412,6 +1414,11 @@ again:
1412 ptr_end = ptr + item_size; 1414 ptr_end = ptr + item_size;
1413 while (ptr < ptr_end) { 1415 while (ptr < ptr_end) {
1414 di = (struct btrfs_dir_item *)ptr; 1416 di = (struct btrfs_dir_item *)ptr;
1417 if (verify_dir_item(root, eb, di)) {
1418 ret = -EIO;
1419 goto out;
1420 }
1421
1415 name_len = btrfs_dir_name_len(eb, di); 1422 name_len = btrfs_dir_name_len(eb, di);
1416 name = kmalloc(name_len, GFP_NOFS); 1423 name = kmalloc(name_len, GFP_NOFS);
1417 if (!name) { 1424 if (!name) {