aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@gmail.com>2014-05-23 15:15:16 -0400
committerChris Mason <clm@fb.com>2014-06-09 20:21:00 -0400
commit7e3ae33efad1490d01040f552ef50e58ed6376ca (patch)
tree4c8081e117a47dc5f0185b179bc2956e2ac6f40c /fs
parent1af56070e3ef9477dbc7eba3b9ad7446979c7974 (diff)
Btrfs: send, use the right limits for xattr names and values
We were limiting the sum of the xattr name and value lengths to PATH_MAX, which is not correct, specially on filesystems created with btrfs-progs v3.12 or higher, where the default leaf size is max(16384, PAGE_SIZE), or systems with page sizes larger than 4096 bytes. Xattrs have their own specific maximum name and value lengths, which depend on the leaf size, therefore use these limits to be able to send xattrs with sizes larger than PATH_MAX. A test case for xfstests follows. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/send.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 15cdc67ce9ad..6528aa662181 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -975,7 +975,7 @@ static int iterate_dir_item(struct btrfs_root *root, struct btrfs_path *path,
975 struct btrfs_dir_item *di; 975 struct btrfs_dir_item *di;
976 struct btrfs_key di_key; 976 struct btrfs_key di_key;
977 char *buf = NULL; 977 char *buf = NULL;
978 const int buf_len = PATH_MAX; 978 int buf_len;
979 u32 name_len; 979 u32 name_len;
980 u32 data_len; 980 u32 data_len;
981 u32 cur; 981 u32 cur;
@@ -985,6 +985,11 @@ static int iterate_dir_item(struct btrfs_root *root, struct btrfs_path *path,
985 int num; 985 int num;
986 u8 type; 986 u8 type;
987 987
988 if (found_key->type == BTRFS_XATTR_ITEM_KEY)
989 buf_len = BTRFS_MAX_XATTR_SIZE(root);
990 else
991 buf_len = PATH_MAX;
992
988 buf = kmalloc(buf_len, GFP_NOFS); 993 buf = kmalloc(buf_len, GFP_NOFS);
989 if (!buf) { 994 if (!buf) {
990 ret = -ENOMEM; 995 ret = -ENOMEM;
@@ -1006,12 +1011,23 @@ static int iterate_dir_item(struct btrfs_root *root, struct btrfs_path *path,
1006 type = btrfs_dir_type(eb, di); 1011 type = btrfs_dir_type(eb, di);
1007 btrfs_dir_item_key_to_cpu(eb, di, &di_key); 1012 btrfs_dir_item_key_to_cpu(eb, di, &di_key);
1008 1013
1009 /* 1014 if (type == BTRFS_FT_XATTR) {
1010 * Path too long 1015 if (name_len > XATTR_NAME_MAX) {
1011 */ 1016 ret = -ENAMETOOLONG;
1012 if (name_len + data_len > buf_len) { 1017 goto out;
1013 ret = -ENAMETOOLONG; 1018 }
1014 goto out; 1019 if (name_len + data_len > buf_len) {
1020 ret = -E2BIG;
1021 goto out;
1022 }
1023 } else {
1024 /*
1025 * Path too long
1026 */
1027 if (name_len + data_len > buf_len) {
1028 ret = -ENAMETOOLONG;
1029 goto out;
1030 }
1015 } 1031 }
1016 1032
1017 read_extent_buffer(eb, buf, (unsigned long)(di + 1), 1033 read_extent_buffer(eb, buf, (unsigned long)(di + 1),