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

Configure Feed

Select the types of activity you want to include in your feed.

soc: qcom: mdt_loader: Actually use the e_phoff

Rather than relying/assuming that the tools generating the firmware
places the program headers immediately following the ELF header, use
e_phoff as intended to find the program headers.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250610-mdt-loader-validation-and-fixes-v2-3-f7073e9ab899@oss.qualcomm.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Bjorn Andersson and committed by
Bjorn Andersson
47e339ca cd840362

+5 -5
+5 -5
drivers/soc/qcom/mdt_loader.c
··· 117 117 return -EINVAL; 118 118 119 119 ehdr = (struct elf32_hdr *)fw->data; 120 - phdrs = (struct elf32_phdr *)(ehdr + 1); 120 + phdrs = (struct elf32_phdr *)(fw->data + ehdr->e_phoff); 121 121 122 122 for (i = 0; i < ehdr->e_phnum; i++) { 123 123 phdr = &phdrs[i]; ··· 172 172 return ERR_PTR(-EINVAL); 173 173 174 174 ehdr = (struct elf32_hdr *)fw->data; 175 - phdrs = (struct elf32_phdr *)(ehdr + 1); 175 + phdrs = (struct elf32_phdr *)(fw->data + ehdr->e_phoff); 176 176 177 177 if (ehdr->e_phnum < 2) 178 178 return ERR_PTR(-EINVAL); ··· 255 255 return -EINVAL; 256 256 257 257 ehdr = (struct elf32_hdr *)fw->data; 258 - phdrs = (struct elf32_phdr *)(ehdr + 1); 258 + phdrs = (struct elf32_phdr *)(fw->data + ehdr->e_phoff); 259 259 260 260 for (i = 0; i < ehdr->e_phnum; i++) { 261 261 phdr = &phdrs[i]; ··· 310 310 int i; 311 311 312 312 ehdr = (struct elf32_hdr *)fw->data; 313 - phdrs = (struct elf32_phdr *)(ehdr + 1); 313 + phdrs = (struct elf32_phdr *)(fw->data + ehdr->e_phoff); 314 314 315 315 for (i = 0; i < ehdr->e_phnum; i++) { 316 316 /* ··· 355 355 356 356 is_split = qcom_mdt_bins_are_split(fw, fw_name); 357 357 ehdr = (struct elf32_hdr *)fw->data; 358 - phdrs = (struct elf32_phdr *)(ehdr + 1); 358 + phdrs = (struct elf32_phdr *)(fw->data + ehdr->e_phoff); 359 359 360 360 for (i = 0; i < ehdr->e_phnum; i++) { 361 361 phdr = &phdrs[i];