From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by sourceware.org (Postfix) with ESMTPS id 2CE753858D1E for ; Mon, 6 Feb 2023 01:41:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2CE753858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x102a.google.com with SMTP id o16-20020a17090ad25000b00230759a8c06so6873564pjw.2 for ; Sun, 05 Feb 2023 17:41:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ToHoKwQNQ/wrcxyZWYMW3IvMuh+dhTHd27MWpdlqjlA=; b=GXCx5r2FgOZnmm09OtOBFpycYqNsmpOSXGGSx3IQBKsZLlhfvZ7/bRsu/Xdy2O5O8w 7FH4+fn3yvo6Pv0y1tvXO7FEn4xj7VaEBJaTTyecVhMJ6ykV/vUxT/KCcj9adZvlwfVd etn2xHhwADXXQ3/d8b4wYowik0h/hgfBT9qWmt+p3Hs0+2jKhSTsNp/piKEZAhpwUQij h9OiNkAEIHYehJSpXpj7jZon8eNSFLadx11PKOnpdBZ9+w46Oj4/vnVrqGywi+dFMGfI q81vNnvLteusxQbn6MqWjMMcZbWJCZMSomQlghcIWTxXiXMe0eqX6ZXa2V8sEZ+BKRzu 9TZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ToHoKwQNQ/wrcxyZWYMW3IvMuh+dhTHd27MWpdlqjlA=; b=PW9O7g24isVBzQyG8OyP96lX2obnMLwwbDn2vGZ5dL1/lwc6raYU3fUp2/fS2EJW9q PIi3YW/v/CCdlu8NjN7f/jZle+oLFaAnRolXLZxQgw21pYhd+yMQMKlZ70MTBx/f3Mej jXiKFeiGI3QKKuOr5uqBdZVh3tE2M4bKIQmZXl2E/i50OfcRvSiPAUACvjceIAEIgp37 w6EdJudTo50D/19LB2Z77NicR3yni2QLntxlDyhDZA8NbrmSJeR13xKUvFInKUfHWvjm Ud7TewUsemCQGltHZ8FOHgmeznPk1247VpoEkSqpB5es6Km4CXAIjCYEFqCGsHAAkoV5 us+g== X-Gm-Message-State: AO0yUKWrjsAzDAyEZXRqS3O36d7UD2yQlhfSUQN4fNs5Gu8IKYYNW9ym /GdSzPVceAEz3G0aGBpIM/EQSkntjQ8= X-Google-Smtp-Source: AK7set/pcPiwSfT+yONESfv9HMzZZEngk9A9TfU75uzY1SlsT9FdBPA9LWxUEMFNyoPmO1FVBbGVaw== X-Received: by 2002:a05:6a20:b559:b0:bf:488a:1daf with SMTP id ev25-20020a056a20b55900b000bf488a1dafmr15368175pzb.12.1675647684978; Sun, 05 Feb 2023 17:41:24 -0800 (PST) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:98b3:a847:f0e5:d0c8]) by smtp.gmail.com with ESMTPSA id y6-20020a63ad46000000b00476dc914262sm223826pgo.1.2023.02.05.17.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Feb 2023 17:41:24 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 2FFD21142DDD; Mon, 6 Feb 2023 12:11:22 +1030 (ACDT) Date: Mon, 6 Feb 2023 12:11:22 +1030 From: Alan Modra To: Jan Beulich Cc: binutils@sourceware.org Subject: Re: Recursion in as_info_where Message-ID: References: <2d6291d4-7307-079b-1cfe-54ae6eb0f951@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3035.0 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: On Fri, Feb 03, 2023 at 02:44:06PM +0100, Jan Beulich wrote: > On 01.02.2023 12:59, Alan Modra wrote: > > On Wed, Feb 01, 2023 at 10:24:25AM +0100, Jan Beulich wrote: > >> On 01.02.2023 07:36, Alan Modra via Binutils wrote: > >>> This function has a gas_assert, ie. possible call to as_abort, which > >>> calls as_report_context, which calls as_info_where. Attached fuzzer > >>> testcase managed to trigger a stack overflow. > >>> > >>> * messages.c (as_info_where): Don't gas_assert. > >>> > >>> diff --git a/gas/messages.c b/gas/messages.c > >>> index 0db075d779c..7c018acf69f 100644 > >>> --- a/gas/messages.c > >>> +++ b/gas/messages.c > >>> @@ -141,8 +141,6 @@ as_info_where (const char *file, unsigned int line, unsigned int indent, > >>> va_list args; > >>> char buffer[2000]; > >>> > >>> - gas_assert (file != NULL && line > 0 && indent <= INT_MAX); > >> > >> If this go in the way, isn't it that the assertion actually triggered? > >> In which case shouldn't the cause for it triggering be addressed > >> instead, to avoid subsequent knock-on damage (e.g. from de-referencing > >> "file"? (I may want to play with the testcase a little myself.) > > > > The testcase is really weird, something that no programmer would ever > > write. It failed the assert with line == 0. I'll let you discover > > the horrible "# line file" with embedded \0 that gets you there. :-) > > Sure. That's an interaction bug between read_a_source_file()'s bumping > of line numbers and s_linefile() trying to compensate. I have a fix for > that, but I'll want to give it wider testing before posting. > > As to the assertion here, I'd prefer if we would keep it, and do e.g. > the below instead. Thoughts? I think it is bad practice for a low-level error handling function to assert. -- Alan Modra Australia Development Lab, IBM