Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

IB/hfi1: Ensure ucast_dlid access doesnt exceed bounds

The dlid assignment made by looking into the u_ucast_dlid array does not
do an explicit check for the size of the array. The code path to arrive at
def_port, the index value is long and complicated so its best to just have
an explicit check here.

Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

authored by

Dennis Dalessandro and committed by
Jason Gunthorpe
3144533b 15b796bc

+2 -1
+2 -1
drivers/infiniband/ulp/opa_vnic/opa_vnic_encap.c
··· 351 351 if (unlikely(!dlid)) 352 352 v_warn("Null dlid in MAC address\n"); 353 353 } else if (def_port != OPA_VNIC_INVALID_PORT) { 354 - dlid = info->vesw.u_ucast_dlid[def_port]; 354 + if (def_port < OPA_VESW_MAX_NUM_DEF_PORT) 355 + dlid = info->vesw.u_ucast_dlid[def_port]; 355 356 } 356 357 } 357 358