From 2270ad3c85802d5fcd3cfcbd8bd109991d8d686f Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Thu, 27 Apr 2017 18:29:09 +0800 Subject: [PATCH] LU-9412 lfs: A invalid memory write in llapi_layout_to_lum When lum is realloc(), the comp_v1 needs to be updated, otherwise it could point to the old invalid memory area. Signed-off-by: Bobi Jam Change-Id: I4493e5f13bce22dae07200bada14ba2349635890 Reviewed-on: https://review.whamcloud.com/26858 Reviewed-by: Niu Yawei Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin --- lustre/utils/liblustreapi_layout.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lustre/utils/liblustreapi_layout.c b/lustre/utils/liblustreapi_layout.c index 83bab13..557765d 100644 --- a/lustre/utils/liblustreapi_layout.c +++ b/lustre/utils/liblustreapi_layout.c @@ -560,6 +560,7 @@ llapi_layout_to_lum(const struct llapi_layout *layout) goto error; } else { lum = blob; + comp_v1 = (struct lov_comp_md_v1 *)lum; blob = (struct lov_user_md *)((char *)lum + lum_size); lum_size += blob_size; } @@ -611,7 +612,7 @@ llapi_layout_to_lum(const struct llapi_layout *layout) lmm_objects[i].l_ost_idx = comp->llc_objects[i].l_ost_idx; - if (comp_v1 != NULL) { + if (layout->llot_is_composite) { ent = &comp_v1->lcm_entries[ent_idx]; ent->lcme_id = comp->llc_id; ent->lcme_flags = comp->llc_flags; -- 1.8.3.1