From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id 14C1A384AB6D for ; Thu, 11 Apr 2024 07:37:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 14C1A384AB6D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 14C1A384AB6D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712821053; cv=none; b=aSyh1mXuWxUm9mP8S+UlmuLwPzM/AGnS+sie77mcoA6kofwbULKYI+QkdUQbbMgX72F0/K1sT6wOL7j6dtk6raVuXphcq7y17yfPrSPT74jYhpIP+wGdaF1tQ/icX6uKEnph1/4Ke0H8z82BdPKujmdxa4cCaR8wLlTX+k49Y5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712821053; c=relaxed/simple; bh=nipaBsLtG+YoVMbAu6xUEN4AHb0bR8/nlV5dYMWDw9c=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=NeLlhOtOYEQTlymGfp+4diFY1L4e4NG4qW2pK86ZcNO1L0obsjSKVbD2VkOPvTAnErWpll/4soYCbWWj5kzOu8DIO9dcgAZbYTc/D2FmrXE5hShOdAJ0Rod64EnndvF6i1zOjXk7mHlrJ81JyXOlPcN/e4MFCnCRvyhXQk+JYQI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6edb76d83d0so1573465b3a.0 for ; Thu, 11 Apr 2024 00:37:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712821049; x=1713425849; darn=sourceware.org; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=LGy74r56FPhOokdfTjxrtVn24qcShcUDCFnOu/Um7x0=; b=SXBUaQyt7l/PM2IMgs1IvtI0GUp+uOT+6odiSOvppFjwepfdj3JsUE1ZXPQvSZ1vQE ln1UpTRunMHTG3on9GHl8rKqYMmc1nARW2Uj6mw9nny03XJvEoi9P3+yWivUYY2yTf08 gChbdna31023rrcLS5LG8NSkmeFt21+qgdNTthVuia7niYB53FZTDcl48CI3AXbTSMW/ Y/zaE9rnLCN4+yTqnObJCLolxC+ApRb0gBCE0yNXKf68AFpvQIHexASMtfgaBLQKgsAh A4qr5s1BoN2haTLKr6C01PdkOdT2KHUwD9v7HvT0BUc4mIh9qr89hZUV15S/UqxRhlrw bHng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712821049; x=1713425849; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LGy74r56FPhOokdfTjxrtVn24qcShcUDCFnOu/Um7x0=; b=uZH23BPoH2XGoxdscDuHX1czixLbDf/HL/223AER1RmafFeekyWioGt0NZw2wytK/V e4zpBeUUF5umwEozx5KZ6voJsMHiwhvI840xSi+uwLWjY1reb1aUjTcbaNeaODKJs4WJ /NgyD4mC6NDOPillR5FH80iJsTa95Jp5ifbT1n6YdiU+yrT22pRcjCOk5koAkj2KJ8nz +USAt47/AIpZY2KqV5g2vT19PBdUwkJtzXV1Z7T2cBmbX3sZ/rbs5d+aLwJ1wAoPVqKZ pfooBxKDamqpg91oB5VcMaaNNLnf+VGSCDFeF14mGwNzKWzC2p+g8MzL5boVMw3RzRhD 7sIw== X-Gm-Message-State: AOJu0YxibWovogqFl3u0yxkEFLlHgVOmdFFCiWbzo5QN6RRRspnlWJAi GTIe3q8RjV6gL5r3Yq7K44jmOeRgFK7NSZCmenrwcaAUzDCRSpHlQDArLA== X-Google-Smtp-Source: AGHT+IEqvDbPVrYToYDwV7Ed1tJqJlBq8tQHcB+y7jGlWYqEEJb4cn4Y1E4hvjvimj2L+ztg5fEMvg== X-Received: by 2002:a05:6a00:3a1d:b0:6ec:ec1b:b7aa with SMTP id fj29-20020a056a003a1d00b006ecec1bb7aamr4855236pfb.22.1712821049516; Thu, 11 Apr 2024 00:37:29 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:da25:346f:5e55:47ce]) by smtp.gmail.com with ESMTPSA id u12-20020a056a00124c00b006ed93e7ef22sm696368pfi.39.2024.04.11.00.37.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 00:37:29 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id C8CCC1140E07; Thu, 11 Apr 2024 17:07:26 +0930 (ACST) Date: Thu, 11 Apr 2024 17:07:26 +0930 From: Alan Modra To: binutils@sourceware.org Subject: asan: heap buffer overflow elf_link_add_to_first_hash Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3032.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 =-prefixed with empty, quoted mmix +FAIL: sysroot-prefix common plain =-prefixed with empty, unquoted 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 =-prefixed -Lpath, quoted mmix +FAIL: sysroot-prefix common plain =-prefixed -Lpath, unquoted mmix +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, quoted mmix +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, unquoted mmix +FAIL: sysroot-prefix common full-path =-prefixed without, quoted mmix +FAIL: sysroot-prefix common full-path =-prefixed without, unquoted mmix +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, quoted mmix +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, unquoted ==3746597==ERROR: AddressSanitizer: heap-buffer-overflow on address 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/binutils-gdb/bfd/elflink.c:4312 mmix uses bfd_link_generic_hash_table. * elflink.c (_bfd_elf_archive_symbol_lookup): Dont use first_hash unless the hash table is bfd_link_elf_hash_table. (elf_link_add_archive_symbols): Likewise. 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; } @@ -6258,6 +6259,8 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info) /* Symbol must be defined. Don't check it again. */ included[i] = true; + 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) -- Alan Modra Australia Development Lab, IBM