UBSAN: Undefined behaviour in drivers/scsi/megaraid/megaraid_sas_fp.c:117:32
index 255 is out of range for type 'MR_LD_SPAN_MAP [1]'

This commit 51087a8617fe (megaraid_sas : Extended VD support) defined those,

struct MR_FW_RAID_MAP {
  u8 ldTgtIdToLd[MAX_RAIDMAP_LOGICAL_DRIVES+\
                 MAX_RAIDMAP_VIEWS];
  struct MR_LD_SPAN_MAP  ldSpanMap[1];

struct MR_FW_RAID_MAP_ALL {
  struct MR_FW_RAID_MAP raidMap;

struct MR_LD_RAID *MR_LdRaidGet(u32 ld, struct MR_DRV_RAID_MAP_ALL *map)
  return &map->raidMap.ldSpanMap[ld].ldRaid;

Then, there are several paths could trigger that undefined behavior due to
out-of-bound access.

mr_update_load_balance_params
  for (ldCount = 0; ldCount < MAX_LOGICAL_DRIVES_EXT;\
       ldCount++;
    ld = MR_TargetIdToLdGet(ldCount, drv_map);
    raid = MR_LdRaidGet(ld, drv_map)

megasas_build_io_fusion
  megasas_build_ld_nonrw_fusion
    ld = MR_TargetIdToLdGet(device_id, local_map_ptr);
    raid = MR_LdRaidGet(ld, local_map_ptr);

Any clue?

Reply via email to