From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) by sourceware.org (Postfix) with ESMTPS id 59DF8382DE11 for ; Wed, 26 Oct 2022 17:05:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 59DF8382DE11 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-yb1-xb2a.google.com with SMTP id r3so19740235yba.5 for ; Wed, 26 Oct 2022 10:05:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Iq+DQsX+D6XJcOcjn0dOgIBXPNfnePCDS2LENT3pPfQ=; b=CVioN0B3kqxMRq9gtH2rOnp16/lTTdwLCryN1joqJaEF90+FYonl/VXmqQ7B9HTsA4 daukt1c4gfcUt0uw08vREdYE05SkapyxNuVn+3jdW9qtMehigJOLYQhsiTEqPykRBy7e kFQFbG5JUjGszglmBZcyIWGP0zpi9n5MjwmFMLNmr3OaDWnEUcLDUpAr/LBA84jwVMaj DBRD3FwKB5fvaufWxdmWuyddaYwEa0lqcI4pkmcQjNxCuRP7/QZ0WapJDOOzFLtz/PBf 0l2elWSVtgtAK8lSJgCWz8/qenEqumGX5KDfsBSWovySAKxhIQT0puzvnyGB//XgfCic 0RCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=Iq+DQsX+D6XJcOcjn0dOgIBXPNfnePCDS2LENT3pPfQ=; b=bX4LtdyIOxyBlLteuZlHBss15SxFkqA1aQmviuqKJKO3xlyQGRi6mVKYYQnA/hN8Gi ztKGzz6B3uEESWekvG93RrfNgj1MnSz1njsH7jYw3F/tIK1cGEKyJ/TevDTWW4QdkzxY Z4M2hcYdRK0gsUNeq55qd2oGN145KWL0JdfA0Hnt/HTknJBiVHY7dT1IK5PFd/OAuqfz s0nOF1thpLbavoYKG0Zu+SHHRK67BCQpPX0EjdxQ1Ok40RR1pV2sFvpbolaKIvJZBs39 udVr9yKu3Sv7Ge09ozGfrCizjzzsvKZKSlDvoYcq67V/OLCU98BQvia49oDfovRyM9vB ilzQ== X-Gm-Message-State: ACrzQf3+us8WYBc9SNBVyVetuECpCbeHavz4BTosJfMQxTup4aJRV7en oBwn+KrwyWOvcOIZHPuFHmmZUb9n1134fgYHX9M= X-Google-Smtp-Source: AMsMyM6iG8BsHXnyyWDjwBwAtIUimcE0KfzgQaPgjIeErlXsvSrt3HCOTPg4jI9+7FjmG8Vu/luPxEPm8F7x5EW/NeM= X-Received: by 2002:a25:7c07:0:b0:6cb:a925:8c02 with SMTP id x7-20020a257c07000000b006cba9258c02mr3054716ybc.70.1666803934572; Wed, 26 Oct 2022 10:05:34 -0700 (PDT) MIME-Version: 1.0 References: <7e3fe210-6dbc-fc29-dbb8-b951e89cf7e9@yahoo.co.jp> <87f124f0-8a10-6c3b-6b12-cabf855e2e4b@yahoo.co.jp> <3296b387-083a-40cf-1bb5-40269e804f52@yahoo.co.jp> <3054719f-6688-211c-da07-93c0fbf7c038@yahoo.co.jp> <20221025200957.v5yjre2fsbxqby43@lug-owl.de> <9871cd37-f2da-ad03-3083-22ff70422ddc@yahoo.co.jp> In-Reply-To: <9871cd37-f2da-ad03-3083-22ff70422ddc@yahoo.co.jp> From: Max Filippov Date: Wed, 26 Oct 2022 10:05:23 -0700 Message-ID: Subject: Re: [PATCH] xtensa: Fix out-of-bounds array access To: "Takayuki 'January June' Suwa" Cc: GCC Patches , Jan-Benedict Glaw Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,FROM_LOCAL_NOVOWEL,HK_RANDOM_ENVFROM,HK_RANDOM_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,WEIRD_PORT autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, Oct 25, 2022 at 11:27 PM Takayuki 'January June' Suwa wrote: > > On 2022/10/26 5:09, Jan-Benedict Glaw wrote: > > I didn't yet actually check the warning, it may be bogus. > > This "problem" can occur in the following two places calling xtensa_split_DI_reg_imm(): > > - (define_expand "movdi") @ line 943-945 > - (define_split) @ line 989 > > and the former causes the "real" problem: > > [from gcc/insn-emit.cc (generated by building)] > > > /* ../../gcc/config/xtensa/xtensa.md:932 */ > > rtx > > gen_movdi (rtx operand0, > > rtx operand1) > > { > > rtx_insn *_val = 0; > > start_sequence (); > > { > > rtx operands[2]; // only 2 elements > > operands[0] = operand0; > > operands[1] = operand1; > > #define FAIL return (end_sequence (), _val) > > #define DONE return (_val = get_insns (), end_sequence (), _val) > > #line 936 "../../gcc/config/xtensa/xtensa.md" > > { > > if (CONSTANT_P (operands[1])) > > { > > /* Split in halves if 64-bit Const-to-Reg moves > > because of offering further optimization opportunities. */ > > if (register_operand (operands[0], DImode)) > > { > > xtensa_split_DI_reg_imm (operands); // out-of-bounds! > > emit_move_insn (operands[0], operands[1]); > > emit_move_insn (operands[2], operands[3]); // out-of-bounds! > > DONE; > > } > > The latter is not a problem as the array is large enough (up to MAX_RECOG_OPERANDS-1). > > === > > gcc/ChangeLog: > > * config/xtensa/xtensa.md (movdi): > Copy operands[0...1] to ops[0...3] and then use the latter before > calling xtensa_split_DI_reg_imm() and emitting insns. > --- > gcc/config/xtensa/xtensa.md | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) Committed to master as obvious after cleaning up the commit message. -- Thanks. -- Max