[PATCH 4/4] efi: Fix use-after-free in finish boot services

2023-05-22 Thread Alec Brown
In grub-core/kern/efi/mm.c, grub_efi_finish_boot_services() has an instance where the memory for the variable finish_mmap_buf is freed, but on the next iteration of a while loop, grub_efi_get_memory_map() uses finish_mmap_buf. To prevent this, we can set finish_mmap_buf to NULL after the free. Sig

[PATCH 3/4] elf: check program header offset doesn't exceed constraints

2023-05-22 Thread Alec Brown
In grub-core/loader/multiboot_elfxx.c, we need to make sure that the program header offset is less than the file size along with the MULTIBOOT_SEARCH constant. We can do so by setting the variable phlimit to the minimum value of the two limits and check it each time we change program header index t

[PATCH 1/4] elf: Check program memory isn't larger than allocated memory size

2023-05-22 Thread Alec Brown
In grub-core/loader/multiboot_elfxx.c, the code is filling an area of memory with grub_memset() but doesn't check if there is space in the allocated memory before doing so. To make sure we aren't zeroing memory past the allocated memory region, we need to check that the offset into the allocated me

[PATCH 2/4] elf: Check section header region before allocating memory

2023-05-22 Thread Alec Brown
In grub-core/loader/multiboot_elfxx.c, space is being allocated for the section header region, but isn't verifying if the region is within the file's size. Before calling grub_calloc(), we can add a conditional to check if the section header region is smaller than the file size. Fixes: CID 314029

[PATCH 0/4] Address coverity untrusted loop bound bugs in multiboot_elfxx.c

2023-05-22 Thread Alec Brown
Coverity has listed two untrusted loop bound bugs in grub-core/loader/multiboot_elfxx.c. They are CID 314029 and CID 314038. After testing the first patch, the CID changed to an untrusted loop bound for line 244: shdr = grub_calloc (shnum, ehdr->e_shentsize);. I added a second patch to address this

[PATCH 1/1] xfs: Fix issues found while fuzzing the XFS filesystem

2023-05-22 Thread Lidong Chen
From: Darren Kenny While performing fuzz testing with XFS filesystem images with ASAN enabled, several issues were found where the memory accesses are made beyond the data that is allocated into the struct grub_xfs_data structure's data field. The existing stucture didn't store the size of the m