From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by sourceware.org (Postfix) with ESMTPS id 73C17385F014 for ; Fri, 28 Jan 2022 17:50:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 73C17385F014 Received: by mail-pj1-x1030.google.com with SMTP id q63so7087048pja.1 for ; Fri, 28 Jan 2022 09:50:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=+koLFWJM9EBA9PUULKfJ3me6GZwoqwq+QNtQhNLJQWw=; b=qlz7PKjVKvwBrvl50wxw7+Hci6KtzlVX2uax1HUV1ZzKXPTS8z6kcGfq6BeQolrBvA tV/pJw4BGc5msVimSbrrLljjr12d/NnP5drHdWh4O1+dZr8e0G3Dm47JrNqJbzBbRwje PoMA2UotBMPygtfdue6tTzncGetKJTbWUVm6u7bWY/3eIxSTpFDplEflcmdS4SB7CTgC oiB5ZK+ANZjVgkkDuwn0PRHCIYk1h8J1Sg6rCZjfwZGoLlgMWp1mERCeEJdl6mSe+ZAT JQv/5mPxpkKbAkNxugPnhgsHSEQFk6VCyztWhDWTaddAs2X+2VxH180ASC/Laxd4sJKL FXoA== X-Gm-Message-State: AOAM533aZSZ28v3AKy/KXOt5p0McRFne2E5ieXlIajFJ6oys8N2c4HQF n0EmhLKX+4jH0c+DRPkqtV/cQvbfqKCMpg== X-Google-Smtp-Source: ABdhPJzAy3QXJheLVv1dyBMZHLlxzOmJQdwJ4759fjBhyLrf1osvQdYwr73ecnzRRrXVjRg17qjHDA== X-Received: by 2002:a17:902:e302:: with SMTP id q2mr9485838plc.92.1643392245593; Fri, 28 Jan 2022 09:50:45 -0800 (PST) Received: from [192.168.1.15] (65-130-85-11.slkc.qwest.net. [65.130.85.11]) by smtp.gmail.com with ESMTPSA id x126sm2364480pgb.85.2022.01.28.09.50.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Jan 2022 09:50:45 -0800 (PST) Message-ID: Date: Fri, 28 Jan 2022 10:50:43 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: RFA: libiberty: Fix infinite recursion in rust demangler (PRs 98886 and 99935) Content-Language: en-US To: Nick Clifton , gcc-patches@gcc.gnu.org References: <87lez25xcy.fsf@redhat.com> From: Jeff Law In-Reply-To: <87lez25xcy.fsf@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jan 2022 17:50:47 -0000 On 1/26/2022 8:29 AM, Nick Clifton via Gcc-patches wrote: > Hi Guys, > > I would like to propose the patch below to fix a couple of sources > of infinite recursion in libiberty's rust demangling code. This patch > is based upon the one submitted for PR 99935, but extended to cope > with the case presented in PR 98886 and also fixed so that the "uint" > type is not used. > > Tested with a patched version of the binutils sources on an > x86-pc-linux-gnu target. > > Cheers > Nick > > 2022-01-26 Nick Clifton > > * rust-demangle.c (struct rust_demangler): Add a recursion > counter. > (demangle_path): Increment/decrement the recursion counter upon > entry and exit. Fail if the counter exceeds a fixed limit. > (demangle_type): Likewise. > (rust_demangle_callback): Initialise the recursion counter, > disabling if requested by the option flags. OK.  I'm both amazed and disappointed at how all the demanglers seem to be prone to infinite recursion. jeff