mirror of
https://github.com/torvalds/linux.git
synced 2025-08-15 14:11:42 +02:00
riscv: module: Fix out-of-bounds relocation access
The current code allows rel[j] to access one element past the end of the
relocation section. Simplify to num_relocations which is equivalent to
the existing size expression.
Fixes: 080c4324fa
("riscv: optimize ELF relocation function in riscv")
Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
Reviewed-by: Maxim Kochetkov <fido_max@inbox.ru>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20250409171526.862481-1-samuel.holland@sifive.com
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
This commit is contained in:
parent
e94eb7ea6f
commit
0b4cce68ef
1 changed files with 1 additions and 1 deletions
|
@ -860,7 +860,7 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
|
|||
}
|
||||
|
||||
j++;
|
||||
if (j > sechdrs[relsec].sh_size / sizeof(*rel))
|
||||
if (j == num_relocations)
|
||||
j = 0;
|
||||
|
||||
} while (j_idx != j);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue