-
Bug
-
Resolution: Unresolved
-
Medium
-
None
-
None
-
None
-
3
-
9223372036854775807
lov_foreign_hsm_to_le() in include/uapi/linux/lustre/lustre_idl.h is
supposed to byte-swap the caller-supplied `src` HSM base fields into
the on-disk (little-endian) `dst` buffer embedded in the
lov_foreign_md. Instead it reads and swabs dst's own (uninitialized)
field back into itself, never touching src:
static inline void lov_foreign_hsm_to_le(struct lov_foreign_md *lfm,
struct lov_hsm_base *src)
Compare with the inverse helper, lov_foreign_hsm_to_cpu(), which
correctly reads from src and writes to dst:
dst->lhb_archive_id = __le64_to_cpu(src->lhb_archive_id);
dst->lhb_archive_ver = __le64_to_cpu(src->lhb_archive_ver);
Effect: any code path that serializes an HSM-typed foreign layout
component (e.g. lod_gen_component_ea_foreign() in
lustre/lod/lod_lov.c)
never actually writes the caller's lhb_archive_id/lhb_archive_ver
into
the on-disk lov_foreign_md - dst's pre-existing/uninitialized memory
is swabbed in place instead, and the real values from src are
silently dropped. Only lhb_uuid is copied correctly.
Fix: swab from src into dst, matching lov_foreign_hsm_to_cpu()'s
pattern:
dst->lhb_archive_id = __cpu_to_le64(src->lhb_archive_id);
dst->lhb_archive_ver = __cpu_to_le64(src->lhb_archive_ver);
Found while adding kunit coverage for lod_gen_component_ea_foreign()
under LU-21180.