Bug 29200 - Infinite loop in nm-new
Summary: Infinite loop in nm-new
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.39
: P2 normal
Target Milestone: 2.39
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-30 20:37 UTC by A
Modified: 2022-06-05 09:20 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed: 2022-05-31 00:00:00


Attachments
infinite loop artifacts (7.03 MB, application/zip)
2022-05-30 20:37 UTC, A
Details

Note You need to log in before you can comment on or make changes to this bug.
Description A 2022-05-30 20:37:43 UTC
Created attachment 14122 [details]
infinite loop artifacts

We found an infinite loop in `nm`. We describe our best effort to understand the vulnerability below. We attach the relevant files as well. 

*Location* 
https://github.com/bminor/binutils-gdb/blob/binutils-2_36-branch/libiberty/cp-demangle.c#L1548

*Description*
While loop never terminates, as the intermediate conditional statements are not satisfied. 

*Fix*
Convert while loop to a bounded for loop statement.
Comment 1 Alan Modra 2022-05-31 07:13:25 UTC
This demangler bug is already fixed in the gcc libiberty sources.  It will be fixed for mainline binutils at the next import of libiberty, which I'm about to do.

A simpler reproducer is
c++filt _Z6NU_EH_FRAsrrtDR
Comment 2 Sourceware Commits 2022-05-31 11:45:32 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2918df9368abdedffe2e2be1c93c760d85d545ab

commit 2918df9368abdedffe2e2be1c93c760d85d545ab
Author: Alan Modra <amodra@gmail.com>
Date:   Tue May 31 16:59:12 2022 +0930

    Import libiberty from gcc
    
            PR 29200
    include/
            * ansidecl.h,
            * demangle.h: Import from gcc.
    libiberty/
            * cp-demangle.c,
            * testsuite/demangle-expected: Import from gcc.
Comment 3 A 2022-05-31 18:52:29 UTC
Thanks for the info. Do you think notifying users through a CVE is appropriate, given the exploitable nature (e.g., denial of service)?
Comment 4 Alan Modra 2022-06-05 09:20:44 UTC
No, I don't think a CVE is needed.