diff options
author | Josef Bacik <josef@redhat.com> | 2011-03-16 21:47:17 +0100 |
---|---|---|
committer | Josef Bacik <josef@redhat.com> | 2011-03-17 19:21:41 +0100 |
commit | 22a94d44bd6876a90630338229da6c0436d46593 (patch) | |
tree | 50e5c7dd52ccf9292240de995e5b42b1619bcd82 /fs/btrfs/tree-log.c | |
parent | Btrfs: check return value of btrfs_search_slot properly (diff) | |
download | linux-22a94d44bd6876a90630338229da6c0436d46593.tar.xz linux-22a94d44bd6876a90630338229da6c0436d46593.zip |
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.c | 7 |
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, ptr_end = ptr + item_size; while (ptr < ptr_end) { di = (struct btrfs_dir_item *)ptr; + if (verify_dir_item(root, eb, di)) + return -EIO; name_len = btrfs_dir_name_len(eb, di); ret = replay_one_name(trans, root, path, eb, di, key); BUG_ON(ret); @@ -1412,6 +1414,11 @@ again: ptr_end = ptr + item_size; while (ptr < ptr_end) { di = (struct btrfs_dir_item *)ptr; + if (verify_dir_item(root, eb, di)) { + ret = -EIO; + goto out; + } + name_len = btrfs_dir_name_len(eb, di); name = kmalloc(name_len, GFP_NOFS); if (!name) { |