Attention is currently required from: Jonathan Zhang, Johnny Lin, Paul Menzel, Martin Roth.
Ed Sharma has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/68637 )
Change subject: commonlib/fsp_relocate: Fix Coverity Issues ......................................................................
Patch Set 4:
(3 comments)
Commit Message:
https://review.coreboot.org/c/coreboot/+/68637/comment/3dbf07d6_0833cba2 PS3, Line 18: on my own to test my changes against coverity tests.
Check [CB:69408], I am able to do so.
Done
File src/commonlib/fsp_relocate.c:
https://review.coreboot.org/c/coreboot/+/68637/comment/56813738_1484d084 PS4, Line 230: offset_limit = roffset + rsize; Fixes issue reported as below: Coverity issue: *** CID 1498391: (TAINTED_SCALAR) /src/commonlib/fsp_relocate.c: 229 in pe_relocate() 223 rsize = read_le32(&ophdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size); 224 roffset = read_le32(&ophdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress); 225 printk(FSP_DBG_LVL, "relocation table at offset-%x,size=%x\n", roffset, rsize); 226 // TODO - add support for PE32+ also 227 228 offset = roffset;
CID 1498391: (TAINTED_SCALAR) Using tainted variable "roffset + rsize" as a loop boundary.
229 while (offset < (roffset + rsize)) { 230 uint32_t vaddr; 231 uint32_t rlen, rnum; 232 uint16_t *rdata; 233 uint32_t i; 234 EFI_IMAGE_DATA_DIRECTORY *relocd;
https://review.coreboot.org/c/coreboot/+/68637/comment/1dc1dcdf_2dbcbc5c PS4, Line 258: ptr = &pe_base[aoff]; Fixes the below reported Coverity issue. Coverity Issue: *** CID 1498391: (TAINTED_SCALAR) 250 printk(FSP_DBG_LVL, "\t\treloc type %x offset %x aoff %x, base-0x%x\n", 251 rtype, roff, aoff, img_base_off); 252 switch (rtype) { 253 case EFI_IMAGE_REL_BASED_ABSOLUTE: 254 continue; 255 case EFI_IMAGE_REL_BASED_HIGHLOW:
CID 1498391: (TAINTED_SCALAR) Using tainted variable "aoff" as an index to pointer "pe_base".
256 val = read_le32(&pe_base[aoff]); 257 printk(FSP_DBG_LVL, "Adjusting %p %x -> %x\n", 258 &pe_base[aoff], val, val + delta); 259 write_le32(&pe_base[aoff], val + delta); 260 break; 261 case EFI_IMAGE_REL_BASED_DIR64: