From 20318e34907d90d76759aee6f0cd609640bbb5aa Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Mon, 11 Apr 2022 16:46:32 +0800 Subject: [PATCH] LU-15513 lod: iterate initialized stripe Fix an array out of bounds access. Do not iterate over the component objects in lod_fill_mirrors() to check non-rotational OSTs if the component is unintialized or it is a MDT or RELEASED component. Fixes: 591a990c61 ("LU-15513 lod: skip uninit component in lod_fill_mirrors") Signed-off-by: Bobi Jam Change-Id: I8530cd30fab750c47f15ee9278ec6d68871367cc Reviewed-on: https://review.whamcloud.com/47028 Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/lod/lod_lov.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index 8d87e4d..5444c63 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -610,7 +610,9 @@ int lod_fill_mirrors(struct lod_object *lo) for (i = 0; i < lo->ldo_comp_cnt; i++, lod_comp++) { bool stale = lod_comp->llc_flags & LCME_FL_STALE; bool preferred = lod_comp->llc_flags & LCME_FL_PREF_WR; - bool init = lod_comp_inited(lod_comp); + bool init = (lod_comp->llc_stripe != NULL) && + !(lod_comp->llc_pattern & LOV_PATTERN_F_RELEASED) && + !(lod_comp->llc_pattern & LOV_PATTERN_MDT); int j; pref = 0; @@ -619,7 +621,10 @@ int lod_fill_mirrors(struct lod_object *lo) __u32 idx = lod_comp->llc_ost_indices[j]; struct lod_tgt_desc *ltd; - if (unlikely(idx > lod->lod_ost_descs.ltd_tgts_size)) { + if (lod_comp->llc_stripe[j] == NULL) + continue; + + if (unlikely(idx >= lod->lod_ost_descs.ltd_tgts_size)) { CERROR("%s: "DFID" OST idx %u > max %u\n", lod2obd(lod)->obd_name, PFID(lu_object_fid(&lo->ldo_obj.do_lu)), -- 1.8.3.1