summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormohit84 <moagrawa@redhat.com>2020-11-04 09:02:03 +0530
committerGitHub <noreply@github.com>2020-11-04 09:02:03 +0530
commit2f044c4587c6db3cb82b6128f056ec2ea2bc1b98 (patch)
treec0f2c5d5aeb4abeae99f806b4638bc549f4bc540
parent7ccb1f1878c864e9e06547cad883bf12a90147b3 (diff)
downloadglusterfs-2f044c4587c6db3cb82b6128f056ec2ea2bc1b98.tar.gz
glusterfs-2f044c4587c6db3cb82b6128f056ec2ea2bc1b98.tar.xz
glusterfs-2f044c4587c6db3cb82b6128f056ec2ea2bc1b98.zip
posix: Use CALLOC instead of alloca to allocate memory for xattrs list (#1730)
In case of file is having huge xattrs on backend a brick process is crashed while alloca(size) limit has been crossed 256k because iot_worker stack size is 256k. Use MALLOC to allocate memory instead of using alloca Fixes: #1699 Signed-off-by: Mohit Agrawal <moagrawa@redhat.com> Change-Id: I100468234f83329a7d65b43cbe4e10450c1ccecd
-rw-r--r--xlators/storage/posix/src/posix-gfid-path.c5
-rw-r--r--xlators/storage/posix/src/posix-helpers.c3
-rw-r--r--xlators/storage/posix/src/posix-inode-fd-ops.c12
3 files changed, 15 insertions, 5 deletions
diff --git a/xlators/storage/posix/src/posix-gfid-path.c b/xlators/storage/posix/src/posix-gfid-path.c
index 1b38e9b047..f5a638e5ea 100644
--- a/xlators/storage/posix/src/posix-gfid-path.c
+++ b/xlators/storage/posix/src/posix-gfid-path.c
@@ -117,7 +117,8 @@ posix_get_gfid2path(xlator_t *this, inode_t *inode, const char *real_path,
if (size == 0)
goto done;
}
- list = alloca(size);
+
+ list = GF_MALLOC(size, gf_posix_mt_char);
if (!list) {
*op_errno = errno;
goto err;
@@ -231,6 +232,7 @@ done:
GF_FREE(paths[j]);
}
ret = 0;
+ GF_FREE(list);
return ret;
err:
if (path)
@@ -239,5 +241,6 @@ err:
if (paths[j])
GF_FREE(paths[j]);
}
+ GF_FREE(list);
return ret;
}
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 67db332408..bd93dd2c1e 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -347,7 +347,7 @@ _posix_get_marker_all_contributions(posix_xattr_filler_t *filler)
goto out;
}
- list = alloca(size);
+ list = GF_MALLOC(size, gf_posix_mt_char);
if (!list) {
goto out;
}
@@ -376,6 +376,7 @@ _posix_get_marker_all_contributions(posix_xattr_filler_t *filler)
ret = 0;
out:
+ GF_FREE(list);
return ret;
}
diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c
index 6d54d37e5a..9e88520f23 100644
--- a/xlators/storage/posix/src/posix-inode-fd-ops.c
+++ b/xlators/storage/posix/src/posix-inode-fd-ops.c
@@ -3391,7 +3391,7 @@ posix_get_ancestry_non_directory(xlator_t *this, inode_t *leaf_inode,
goto out;
}
- list = alloca(size);
+ list = GF_MALLOC(size, gf_posix_mt_char);
if (!list) {
*op_errno = errno;
goto out;
@@ -3470,6 +3470,7 @@ posix_get_ancestry_non_directory(xlator_t *this, inode_t *leaf_inode,
op_ret = 0;
out:
+ GF_FREE(list);
return op_ret;
}
@@ -3899,7 +3900,8 @@ posix_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc,
if (size == 0)
goto done;
}
- list = alloca(size);
+
+ list = GF_MALLOC(size, gf_posix_mt_char);
if (!list) {
op_errno = errno;
goto out;
@@ -4026,6 +4028,7 @@ out:
dict_unref(dict);
}
+ GF_FREE(list);
return 0;
}
@@ -4225,7 +4228,8 @@ posix_fgetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, const char *name,
if (size == 0)
goto done;
}
- list = alloca(size + 1);
+
+ list = GF_MALLOC(size, gf_posix_mt_char);
if (!list) {
op_ret = -1;
op_errno = ENOMEM;
@@ -4327,6 +4331,8 @@ out:
if (dict)
dict_unref(dict);
+ GF_FREE(list);
+
return 0;
}