WIP MachO binutils port assisted by AI I may consider upstreaming this in the future.
0

Configure Feed

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

pr 34159, buffer overflow in fr30_elf_i32_reloc

Stop the fuzzed object file buffer overflow, and remove a FIXME.

* elf32-fr30.c (fr30_elf_i20_reloc, fr30_elf_i32_reloc): Handle
ld -r using bfd_elf_generic_reloc. Sanity check reloc offset.

Alan Modra (May 24, 2026, 2:24 PM +0930) 1c6e6d2f 7565cfd7

+15 -26
+15 -26
bfd/elf32-fr30.c
··· 238 238 void * data, 239 239 asection *input_section, 240 240 bfd *output_bfd, 241 - char **error_message ATTRIBUTE_UNUSED) 241 + char **error_message) 242 242 { 243 243 bfd_vma relocation; 244 244 unsigned long x; 245 245 246 - /* This part is from bfd_elf_generic_reloc. */ 247 - if (output_bfd != (bfd *) NULL 248 - && (symbol->flags & BSF_SECTION_SYM) == 0 249 - && (! reloc_entry->howto->partial_inplace 250 - || reloc_entry->addend == 0)) 251 - { 252 - reloc_entry->address += input_section->output_offset; 253 - return bfd_reloc_ok; 254 - } 255 - 256 246 if (output_bfd != NULL) 257 - /* FIXME: See bfd_perform_relocation. Is this right? */ 258 - return bfd_reloc_ok; 247 + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 248 + input_section, output_bfd, error_message); 249 + 250 + if (!bfd_reloc_offset_in_range (reloc_entry->howto, abfd, 251 + input_section, reloc_entry->address)) 252 + return bfd_reloc_outofrange; 259 253 260 254 relocation = 261 255 symbol->value ··· 282 276 void * data, 283 277 asection *input_section, 284 278 bfd *output_bfd, 285 - char **error_message ATTRIBUTE_UNUSED) 279 + char **error_message) 286 280 { 287 281 bfd_vma relocation; 288 282 289 - /* This part is from bfd_elf_generic_reloc. */ 290 - if (output_bfd != (bfd *) NULL 291 - && (symbol->flags & BSF_SECTION_SYM) == 0 292 - && (! reloc_entry->howto->partial_inplace 293 - || reloc_entry->addend == 0)) 294 - { 295 - reloc_entry->address += input_section->output_offset; 296 - return bfd_reloc_ok; 297 - } 298 - 299 283 if (output_bfd != NULL) 300 - /* FIXME: See bfd_perform_relocation. Is this right? */ 301 - return bfd_reloc_ok; 284 + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 285 + input_section, output_bfd, error_message); 286 + 287 + if (reloc_entry->address + 2 < 2 288 + || !bfd_reloc_offset_in_range (reloc_entry->howto, abfd, 289 + input_section, reloc_entry->address + 2)) 290 + return bfd_reloc_outofrange; 302 291 303 292 relocation = 304 293 symbol->value