From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id AA38D384AB62; Thu, 11 Apr 2024 07:39:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA38D384AB62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1712821188; bh=wdmlP0ZibHLJUcxrW0L+iK+/bY9kJ8mCFZgOY0oaLQU=; h=From:To:Subject:Date:From; b=TtXMeMcp9B6I5qmkNWawZokkiNVu29H6QC+8DuM/emdWFF3PvSplDPO9SWPpCJyEQ Cxu1Hjc079m/zxpn5T3uYK4uvrA3ca7VRMqCQYyo5xeUCzawc57Jngd9nFB0Xfk4vz TIXY+gXVhEfKu/RQfNbXM9o/imXCof1qr1bk3tyw= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: binutils-cvs@sourceware.org Subject: [binutils-gdb] asan: heap buffer overflow elf_link_add_to_first_hash X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: ef70c9e7b26ec5e95b073944a9ed19d495c4fe88 X-Git-Newrev: de9dc65bd45c118d56600bbf1786322284fde795 Message-Id: <20240411073948.AA38D384AB62@sourceware.org> Date: Thu, 11 Apr 2024 07:39:48 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dde9dc65bd45c= 118d56600bbf1786322284fde795 commit de9dc65bd45c118d56600bbf1786322284fde795 Author: Alan Modra Date: Thu Apr 11 16:39:18 2024 +0930 asan: heap buffer overflow elf_link_add_to_first_hash =20 Seen on mmix. mmix +FAIL: ld-misc/defsym1 mmix +FAIL: sysroot-prefix common plain -Lpath, quoted mmix +FAIL: sysroot-prefix common plain -Lpath, unquoted mmix +FAIL: sysroot-prefix common full-path, quoted mmix +FAIL: sysroot-prefix common full-path, unquoted mmix +FAIL: sysroot-prefix common plain =3D-prefixed with empty, quoted mmix +FAIL: sysroot-prefix common plain =3D-prefixed with empty, unquo= ted mmix +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, = quoted mmix +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, = unquoted mmix +FAIL: sysroot-prefix common plain =3D-prefixed -Lpath, quoted mmix +FAIL: sysroot-prefix common plain =3D-prefixed -Lpath, unquoted mmix +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, quot= ed mmix +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, unqu= oted mmix +FAIL: sysroot-prefix common full-path =3D-prefixed without, quot= ed mmix +FAIL: sysroot-prefix common full-path =3D-prefixed without, unqu= oted mmix +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without,= quoted mmix +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without,= unquoted =20 =3D=3D3746597=3D=3DERROR: AddressSanitizer: heap-buffer-overflow on add= ress 0x6070000007a0 at pc 0x56d87b0d1a40 bp 0x7fffb1629bf0 sp 0x7fffb1629be0 READ of size 8 at 0x6070000007a0 thread T0 #0 0x56d87b0d1a3f in elf_link_add_to_first_hash /home/alan/src/binu= tils-gdb/bfd/elflink.c:4312 =20 mmix uses bfd_link_generic_hash_table. =20 * elflink.c (_bfd_elf_archive_symbol_lookup): Dont use first_ha= sh unless the hash table is bfd_link_elf_hash_table. (elf_link_add_archive_symbols): Likewise. Diff: --- bfd/elflink.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bfd/elflink.c b/bfd/elflink.c index 22fddb8f56b..321e3d5e2ff 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -6116,7 +6116,8 @@ _bfd_elf_archive_symbol_lookup (bfd *abfd, { /* Add this symbol to first hash if this archive has the first definition. */ - elf_link_add_to_first_hash (abfd, info, name, false); + if (is_elf_hash_table (info->hash)) + elf_link_add_to_first_hash (abfd, info, name, false); return h; } =20 @@ -6258,6 +6259,8 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_l= ink_info *info) /* Symbol must be defined. Don't check it again. */ included[i] =3D true; =20 + if (!is_elf_hash_table (info->hash)) + continue; /* Ignore the archive if the symbol isn't defined in a shared object. */ if (!((struct elf_link_hash_entry *) h)->def_dynamic)