From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb32.google.com (mail-yb1-xb32.google.com [IPv6:2607:f8b0:4864:20::b32]) by sourceware.org (Postfix) with ESMTPS id 0E8A33858D1E for ; Wed, 13 Mar 2024 01:17:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E8A33858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0E8A33858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::b32 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710292657; cv=none; b=ieZp4HHcUjvxjdFpXSE5VyoHjMMYK2sTpCHcz9nrNB23NxNwdBvKMdOG3yKKXnSK+fYSepxM4zOOXXndNDjwODIM3+Axlk2e/KZjTM5rRpxhr42ckziDOrmDaid92/mIUD6rP1k6u+ivk/+Hu5zY4Md6EDKCAN6C9ex14jBnLzE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710292657; c=relaxed/simple; bh=SEOziWL+eQSTdZXfai597JEACQd8229sX7utsTTeagI=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=uHhsIRSPYEATPQ+F/vj3pbHFCAk7mzFJ1vNeuDzzESRAgDp8CrgQ+meBMMmCW0znqyGpWmF2XfPeaScRa49nBkwHlRHrUlPG2C6r9l3fhJndSp2kgqzYzhGYqR92Boe44vr1fdDkKPhzpM908tqw3/SJ5pl/ABLDGiXsZCqqCbc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yb1-xb32.google.com with SMTP id 3f1490d57ef6-dd161eb03afso497619276.0 for ; Tue, 12 Mar 2024 18:17:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710292655; x=1710897455; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=d+OcSaTAyyQMfYysHkqAumv0pfMrhHdJ/f1QJaUL07Y=; b=Z/ycyXHWsdeG4rkNpmdeDZSKl4TDJUvpev/BWxe3WhjpjAR9fbffR9pG3Ca1ecFoEG 0RAl4TqblBNyI6ul5pAQa3hhh8vTUY5gcWTRq1vy8Aujypv5/+0wMt2bJGugTLkbuAZI VBkLWEHQCkNEv9ecEVJRZpSV+kwUzIjJCvkvIOTjTB5J6b8fMPjeFi8bx2VXLvQMEP7L /uVs1NKlixwtnUJzZXF//D8WyDMNCfXrpVcp7imhUa2Q+UFMUm3xvqPIi2iH1eNgZhfv wg0hWBsRy5ZMtltGfJDXWkMhiPsgJRgq2GDOdLW1oWwq/IcFB9llUvBnf64ibhiAVtw7 hb4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710292655; x=1710897455; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d+OcSaTAyyQMfYysHkqAumv0pfMrhHdJ/f1QJaUL07Y=; b=wdlNQ4Jb1X+OYQtxA+JUSueYKqE7NiQHTzhy1+HpXTG/2oXYCrC899RSuexxlqPvlh Med5RZVkf+v3dcwGVGa3rPcHUPlGCaoP754E3c4ehgAvXUR2VolMximt3QxzkBq/n+i7 iVFl/UnyhfPY+W+WAOu26tbkHwifQhbuSS+kq37NkC2Jr1y4iX1P/QkWLlWPvsmj/oI6 ObKZ2XU/dmw2Jw4OztXMAAdg+YpCujaQ+1jypp2TBW9pIldeeOYvMNwcYVKalyxtTB6d ohstPsAJJHahvm6S0c+FSNbFC5IMe+66zunFWFaHyRPl7fXHhxZpy97Ia/N1d82C0alw R16g== X-Gm-Message-State: AOJu0YzWtWjDAJlz+MsLKOQgOF/sOoE67vAwp4q/8+2Ur5LR85R0m4bA Ea6vS8DJkH4Z0DTQXXXs9rb0iYfXaOJBM5Es24J1t2DAjEXBoSpmCLakqjI2lmy8LPqURQG7vFs 14UZS8PWV6oix3krjEnMU/REq6qQ= X-Google-Smtp-Source: AGHT+IHCuRLWr0JYronxW3PWP/3cw9u6WdPMYsl3TXStPSvT8kK0feGbnnXn/J34uYO079yB9kdqGChZczpc+V/IwyQ= X-Received: by 2002:a05:6902:2488:b0:dcf:2cfe:c82e with SMTP id ds8-20020a056902248800b00dcf2cfec82emr1241482ybb.55.1710292655292; Tue, 12 Mar 2024 18:17:35 -0700 (PDT) MIME-Version: 1.0 References: <20240312115759.4067084-1-hongtao.liu@intel.com> In-Reply-To: <20240312115759.4067084-1-hongtao.liu@intel.com> From: Hongtao Liu Date: Wed, 13 Mar 2024 09:27:56 +0800 Message-ID: Subject: Re: [PATCH] sanitizer: [PR110027] Align asan_vec[0] to MAX (alignb, ASAN_RED_ZONE_SIZE) To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org, hjl.tools@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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 Tue, Mar 12, 2024 at 8:00=E2=80=AFPM liuhongt wr= ote: > > if alignb > ASAN_RED_ZONE_SIZE and offset[0] is not multiple of > alignb. (base_align_bias - base_offset) may not aligned to alignb, and > caused segement fault. > > Bootstrapped and regtested on x86_64-linux-gnu{-m32,}. > Ok for trunk and backport to GCC13? CC jakub, I see the code was added by https://gcc.gnu.org/pipermail/gcc-patches/2018-December/512313.html The issue in the PR is similar, but __m512 requires bigger alignment(64 > ASAN_RED_ZONE_SIZE(32)), in that case we need to insert MAX (alignb, ASAN_RED_ZONE_SIZE) instead of ASAN_RED_ZONE_SIZE. Assume when alignb > ASAN_RED_ZONE_SIZE, it must be multiple of ASAN_RED_ZONE_SIZE. > > gcc/ChangeLog: > > PR sanitizer/110027 > * cfgexpand.cc (expand_stack_vars): Align frame offset to > MAX (alignb, ASAN_RED_ZONE_SIZE). > > gcc/testsuite/ChangeLog: > > * g++.dg/asan/pr110027.C: New test. > --- > gcc/cfgexpand.cc | 2 +- > gcc/testsuite/g++.dg/asan/pr110027.C | 20 ++++++++++++++++++++ > 2 files changed, 21 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/g++.dg/asan/pr110027.C > > diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc > index 0de299c62e3..92062378d8e 100644 > --- a/gcc/cfgexpand.cc > +++ b/gcc/cfgexpand.cc > @@ -1214,7 +1214,7 @@ expand_stack_vars (bool (*pred) (size_t), class sta= ck_vars_data *data) > { > if (data->asan_vec.is_empty ()) > { > - align_frame_offset (ASAN_RED_ZONE_SIZE); > + align_frame_offset (MAX (alignb, ASAN_RED_ZONE_SIZE)); > prev_offset =3D frame_offset.to_constant (); > } > prev_offset =3D align_base (prev_offset, > diff --git a/gcc/testsuite/g++.dg/asan/pr110027.C b/gcc/testsuite/g++.dg/= asan/pr110027.C > new file mode 100644 > index 00000000000..0067781bc89 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/asan/pr110027.C > @@ -0,0 +1,20 @@ > +/* PR sanitizer/110027 */ > +/* { dg-do run } */ > +/* { dg-require-effective-target avx512f_runtime } */ > +/* { dg-options "-std=3Dgnu++23 -mavx512f -fsanitize=3Daddress -O0 -g -f= stack-protector-strong" } */ > + > +#include > +#include > + > +template > +using Vec [[gnu::vector_size(W * sizeof(T))]] =3D T; > + > +auto foo() { > + Vec<8, int64_t> ret{}; > + return ret; > +} > + > +int main() { > + foo(); > + return 0; > +} > -- > 2.31.1 > --=20 BR, Hongtao