{"id":2303,"date":"2017-09-26T10:04:33","date_gmt":"2017-09-26T08:04:33","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=2303"},"modified":"2017-09-30T18:58:07","modified_gmt":"2017-09-30T16:58:07","slug":"binutils-memory-allocation-failure-in-_bfd_elf_slurp_version_tables-elf-c","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2017\/09\/26\/binutils-memory-allocation-failure-in-_bfd_elf_slurp_version_tables-elf-c\/","title":{"rendered":"binutils: memory allocation failure in _bfd_elf_slurp_version_tables (elf.c)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"https:\/\/sourceware.org\/binutils\/\">binutils<\/a> is a set of tools necessary to build programs.<\/p>\n<p>This issue was initially discovered because the nm process eat ~230GB of ram. Later on, another testcase hits the issue and now I have a stracktrace.<br \/>\nThe relevant ASan output of the issue:<\/p>\n<pre><font size=\"2\"># nm -A -a -l -S -s --special-syms --synthetic --with-symbol-versions -D $FILE\r\n    #8 0x4d8de4 in malloc \/var\/tmp\/portage\/sys-libs\/compiler-rt-sanitizers-5.0.0\/work\/compiler-rt-5.0.0.src\/lib\/asan\/asan_malloc_linux.cc:68\r\n    #9 0x7fd0deccb41d in _objalloc_alloc \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/libiberty\/objalloc.c:143:22\r\n    #10 0x7fd0de921c24 in bfd_alloc \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/opncls.c:949:9\r\n    #11 0x7fd0de921c24 in bfd_zalloc2 \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/opncls.c:1031\r\n    #12 0x7fd0de9b2db8 in _bfd_elf_slurp_version_tables \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/elf.c:8222:2\r\n    #13 0x7fd0de999da7 in bfd_elf64_slurp_symbol_table \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/elfcode.h:1165:9\r\n    #14 0x7fd0de9ed876 in _bfd_elf_canonicalize_dynamic_symtab \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/elf.c:8099:19\r\n    #15 0x7fd0de935fc7 in _bfd_generic_read_minisymbols \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/bfd\/syms.c\r\n    #16 0x513a53 in display_rel_file \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/binutils\/nm.c:1107:14\r\n    #17 0x510f56 in display_file \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/binutils\/nm.c:1318:7\r\n    #18 0x50faae in main \/var\/tmp\/portage\/sys-devel\/binutils-9999\/work\/binutils\/binutils\/nm.c:1792:12\r\n    #19 0x7fd0dd934680 in __libc_start_main \/var\/tmp\/portage\/sys-libs\/glibc-2.23-r4\/work\/glibc-2.23\/csu\/..\/csu\/libc-start.c:289\r\n    #20 0x41ac18 in _init (\/usr\/x86_64-pc-linux-gnu\/binutils-bin\/git\/nm+0x41ac18)\r\n<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\n2.29.51.20170921 and maybe past releases<\/p>\n<p><strong>Fixed version:<\/strong><br \/>\nN\/A<\/p>\n<p><strong>Commit fix:<\/strong><br \/>\n<a href=\"https:\/\/sourceware.org\/git\/gitweb.cgi?p=binutils-gdb.git;h=bd61e135492ecf624880e6b78e5fcde3c9716df6\">https:\/\/sourceware.org\/git\/gitweb.cgi?p=binutils-gdb.git;h=bd61e135492ecf624880e6b78e5fcde3c9716df6<\/a><\/p>\n<p><strong>Credit:<\/strong><br \/>\nThis bug was discovered by Agostino Sarubbo of Gentoo.<\/p>\n<p><strong>CVE:<\/strong><br \/>\nCVE-2017-14938<\/p>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00368-binutils-memallocfailure-_bfd_elf_slurp_version_tables\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00368-binutils-memallocfailure-_bfd_elf_slurp_version_tables<\/a><\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2017-09-21: bug discovered and reported to upstream<br \/>\n2017-09-24: upstream released a patch<br \/>\n2017-09-26: blog post about the issue<br \/>\n2017-09-29: CVE assigned<\/p>\n<p><strong>Note:<\/strong><br \/>\nThis bug was found with <a href=\"http:\/\/lcamtuf.coredump.cx\/afl\">American Fuzzy Lop<\/a>.<br \/>\nThis bug was identified with bare metal servers donated by <a href=\"https:\/\/www.packet.net\/\">Packet<\/a>. This work is also supported by the <a href=\"https:\/\/www.coreinfrastructure.org\">Core Infrastructure Initiative<\/a>.<\/p>\n<p><strong>Permalink:<\/strong><\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"9XzAt2sLEa\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2017\/09\/26\/binutils-memory-allocation-failure-in-_bfd_elf_slurp_version_tables-elf-c\/\">binutils: memory allocation failure in _bfd_elf_slurp_version_tables (elf.c)<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"http:\/\/blogs.gentoo.org\/ago\/2017\/09\/26\/binutils-memory-allocation-failure-in-_bfd_elf_slurp_version_tables-elf-c\/embed\/#?secret=9XzAt2sLEa\" data-secret=\"9XzAt2sLEa\" width=\"600\" height=\"338\" title=\"&#8220;binutils: memory allocation failure in _bfd_elf_slurp_version_tables (elf.c)&#8221; &#8212; agostino&#039;s blog\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: binutils is a set of tools necessary to build programs. This issue was initially discovered because the nm process eat ~230GB of ram. Later on, another testcase hits the issue and now I have a stracktrace. The relevant ASan &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2017\/09\/26\/binutils-memory-allocation-failure-in-_bfd_elf_slurp_version_tables-elf-c\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":140,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[12,10],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2EaBc-B9","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/2303"}],"collection":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/users\/140"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/comments?post=2303"}],"version-history":[{"count":3,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/2303\/revisions"}],"predecessor-version":[{"id":2316,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/2303\/revisions\/2316"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=2303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=2303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=2303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}