{"id":1596,"date":"2017-04-03T18:33:58","date_gmt":"2017-04-03T16:33:58","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=1596"},"modified":"2017-04-10T09:44:12","modified_gmt":"2017-04-10T07:44:12","slug":"elfutils-memory-allocation-failure-in-xcalloc-xmalloc-c","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2017\/04\/03\/elfutils-memory-allocation-failure-in-xcalloc-xmalloc-c\/","title":{"rendered":"elfutils: memory allocation failure in xcalloc (xmalloc.c)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"https:\/\/sourceware.org\/elfutils\/\">elfutils<\/a> is a set of libraries\/utilities to handle ELF objects (drop in replacement for libelf).<\/p>\n<p>A fuzz on eu-elflint showed a memory allocation failure.<\/p>\n<p>The interesting ASan output:<\/p>\n<pre><font size=\"2\"># eu-elflint -d $FILE\r\n==5053==AddressSanitizer CHECK failed: \/tmp\/portage\/sys-devel\/gcc-6.3.0\/work\/gcc-6.3.0\/libsanitizer\/sanitizer_common\/sanitizer_common.cc:180 \"((0 &amp;&amp; \"unable to mmap\")) != (0)\" (0x0, 0x0)\r\n    #0 0x7faa2335941d  (\/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/6.3.0\/libasan.so.3+0xcb41d)\r\n    #1 0x7faa2335f063 in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (\/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/6.3.0\/libasan.so.3+0xd1063)\r\n    #2 0x7faa2335f24d  (\/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/6.3.0\/libasan.so.3+0xd124d)\r\n    #3 0x7faa23368c52  (\/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/6.3.0\/libasan.so.3+0xdac52)\r\n    #4 0x7faa232ba0b9  (\/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/6.3.0\/libasan.so.3+0x2c0b9)\r\n    #5 0x7faa232b249b  (\/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/6.3.0\/libasan.so.3+0x2449b)\r\n    #6 0x7faa2335040a in calloc (\/usr\/lib\/gcc\/x86_64-pc-linux-gnu\/6.3.0\/libasan.so.3+0xc240a)\r\n    #7 0x431b8d in xcalloc \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/lib\/xmalloc.c:64\r\n    #8 0x41f0bb in check_sections \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/src\/elflint.c:3680\r\n    #9 0x42961f in process_elf_file \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/src\/elflint.c:4697\r\n    #10 0x42961f in process_file \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/src\/elflint.c:242\r\n    #11 0x402d33 in main \/tmp\/portage\/dev-libs\/elfutils-0.168\/work\/elfutils-0.168\/src\/elflint.c:175\r\n    #12 0x7faa21c6378f in __libc_start_main (\/lib64\/libc.so.6+0x2078f)\r\n    #13 0x403498 in _start (\/usr\/bin\/eu-elflint+0x403498)\r\n<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\n0.168<\/p>\n<p><strong>Fixed version:<\/strong><br \/>\n0.169 (not released atm)<\/p>\n<p><strong>Commit fix:<\/strong><br \/>\n<a href=\"https:\/\/sourceware.org\/ml\/elfutils-devel\/2017-q1\/msg00133.html\">https:\/\/sourceware.org\/ml\/elfutils-devel\/2017-q1\/msg00133.html<\/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-7613<\/p>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00236-elfutils-memallocfailure\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00236-elfutils-memallocfailure<\/a><\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2017-03-27: bug discovered and reported to upstream<br \/>\n2017-04-04: blog post about the issue<br \/>\n2017-04-09: 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>.<\/p>\n<p><strong>Permalink:<\/strong><\/p>\n<blockquote data-secret=\"IF3pHYonbL\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2017\/04\/03\/elfutils-memory-allocation-failure-in-xcalloc-xmalloc-c\/\">elfutils: memory allocation failure in xcalloc (xmalloc.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\/04\/03\/elfutils-memory-allocation-failure-in-xcalloc-xmalloc-c\/embed\/#?secret=IF3pHYonbL\" data-secret=\"IF3pHYonbL\" width=\"600\" height=\"338\" title=\"&#8220;elfutils: memory allocation failure in xcalloc (xmalloc.c)&#8221; &#8212; agostino&#039;s blog\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: elfutils is a set of libraries\/utilities to handle ELF objects (drop in replacement for libelf). A fuzz on eu-elflint showed a memory allocation failure. The interesting ASan output: # eu-elflint -d $FILE ==5053==AddressSanitizer CHECK failed: \/tmp\/portage\/sys-devel\/gcc-6.3.0\/work\/gcc-6.3.0\/libsanitizer\/sanitizer_common\/sanitizer_common.cc:180 &#8220;((0 &amp;&amp; &#8220;unable &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2017\/04\/03\/elfutils-memory-allocation-failure-in-xcalloc-xmalloc-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-pK","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1596"}],"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=1596"}],"version-history":[{"count":3,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1596\/revisions"}],"predecessor-version":[{"id":1626,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1596\/revisions\/1626"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=1596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=1596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=1596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}