From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id B0DC13858284 for ; Thu, 24 Nov 2022 10:21:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B0DC13858284 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 6745521AB0; Thu, 24 Nov 2022 10:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1669285285; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=b3g2IW5395CfarmD1LKsR+7o3fxiBkq31mOPGG8+pT8=; b=DCjhODqnKntBQ38J4l/4H9qY0BJlkGootR4Nvgb7vTuyQS263Wtkh9UtsPXDegc62gjzT+ Wh2apiZKbuJ9c2uGPXymDqu98KGajR6idPNBtvOPy/96PBOgUVAB0S4bHrLcYGzq6sLPqD sq1VxZUXgjqu2d7fKitLoQRgojWWq7k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1669285285; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=b3g2IW5395CfarmD1LKsR+7o3fxiBkq31mOPGG8+pT8=; b=DhDcRsScZfibNlV8XvWP+dBMhBxFcKzAgkybrKOhhWew0St8wtvAKQ6Gy3x5O+bPppyXbD fWLnZ/AbVst+ugCw== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 5F2ED2C141; Thu, 24 Nov 2022 10:21:25 +0000 (UTC) Date: Thu, 24 Nov 2022 10:21:25 +0000 (UTC) From: Richard Biener To: Jakub Jelinek cc: Jeff Law , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] asan: Fix up error recovery for too large frames [PR107317] In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Thu, 24 Nov 2022, Jakub Jelinek wrote: > Hi! > > asan_emit_stack_protection and functions it calls have various asserts that > verify sanity of the stack protection instrumentation. But, that > verification can easily fail if we've diagnosed a frame offset overflow. > asan_emit_stack_protection just emits some extra code in the prologue, > if we've reported errors, we aren't producing assembly, so it doesn't > really matter if we don't include the protection code, compilation > is going to fail anyway. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK. > 2022-11-24 Jakub Jelinek > > PR middle-end/107317 > * asan.cc: Include diagnostic-core.h. > (asan_emit_stack_protection): Return NULL early if seen_error (). > > * gcc.dg/asan/pr107317.c: New test. > > --- gcc/asan.cc.jj 2022-06-28 13:03:30.613693889 +0200 > +++ gcc/asan.cc 2022-11-23 17:47:09.130332461 +0100 > @@ -64,6 +64,7 @@ along with GCC; see the file COPYING3. > #include "tree-inline.h" > #include "tree-ssa.h" > #include "tree-eh.h" > +#include "diagnostic-core.h" > > /* AddressSanitizer finds out-of-bounds and use-after-free bugs > with <2x slowdown on average. > @@ -1818,6 +1819,11 @@ asan_emit_stack_protection (rtx base, rt > tree str_cst, decl, id; > int use_after_return_class = -1; > > + /* Don't emit anything when doing error recovery, the assertions > + might fail e.g. if a function had a frame offset overflow. */ > + if (seen_error ()) > + return NULL; > + > if (shadow_ptr_types[0] == NULL_TREE) > asan_init_shadow_ptr_types (); > > --- gcc/testsuite/gcc.dg/asan/pr107317.c.jj 2022-11-23 17:46:09.145219960 +0100 > +++ gcc/testsuite/gcc.dg/asan/pr107317.c 2022-11-23 17:49:45.148024097 +0100 > @@ -0,0 +1,13 @@ > +/* PR middle-end/107317 */ > +/* { dg-do compile { target ilp32 } } */ > +/* { dg-options "-fsanitize=address -ffat-lto-objects" } */ > + > +void bar (float *, float *); > + > +void > +foo (void) /* { dg-error "exceeds maximum" } */ > +{ > + float a[400000000]; > + float b[200000000]; > + bar (a, b); > +} > > Jakub > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)