From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 1B1973858D39 for ; Thu, 30 Jun 2022 22:47:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1B1973858D39 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-640-5i143d4kNPusAyyx0kMw4A-1; Thu, 30 Jun 2022 18:47:29 -0400 X-MC-Unique: 5i143d4kNPusAyyx0kMw4A-1 Received: by mail-qv1-f70.google.com with SMTP id b2-20020a0cb3c2000000b004703a79581dso949183qvf.1 for ; Thu, 30 Jun 2022 15:47:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=L2iuL7ne5ODUsTcn9TAIiYXNn6hT0xvpwfaaIjevbeA=; b=M/AQRhiqPNrC7XQ/qEOrIZtzxxkhA+2rykrHKVp7DW/V9ipQUfPX0jOOR3uSSiStpk eQgTb53UMBCWgD23gwTJh9qMBiaj8zkC9KB4V8mY7zDByx/VofzMJyMtx8bqgXTaRrAu i8GMUhub1yOJ+nLue9MlYeoxiopI35S9AvYWyK3+g3ZF5dx6kISs9As0aPwNOPFKuy5y 1zzo4zAEtXa/UFaj2hrBznqsD0GBmrpcIpKOieHdvY/h7kbtWM4IDsw+DA0MYWSD7blV 5FaDanqV5xf2czDtNKwH+8C2AylpwMr9xLWAhtGvVXWif1hEGipKt3tgSoBw57sDJ5a2 UADw== X-Gm-Message-State: AJIora/7fBNLZV3Znz1+yzb4wzWEoMByVNZYmzLU0c+Sf+sb+lkPnB2y EfqOL/sxZG2ZCE6Lk/JxyzfxSvwJAnqP76AJtFSPknASTLmomxWRQGYIwcYS3nxB98aTz7DBzav Z8ysjRvg= X-Received: by 2002:ad4:594d:0:b0:470:a86f:efe9 with SMTP id eo13-20020ad4594d000000b00470a86fefe9mr13772165qvb.24.1656629248823; Thu, 30 Jun 2022 15:47:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tuCtt3Pbs0FxTUSZQQNr5q7S0ob9mFkNX5dOr9h1O+jtu6HJqr+Ptuq1632bIwbPAC0oPOpg== X-Received: by 2002:ad4:594d:0:b0:470:a86f:efe9 with SMTP id eo13-20020ad4594d000000b00470a86fefe9mr13772149qvb.24.1656629248546; Thu, 30 Jun 2022 15:47:28 -0700 (PDT) Received: from t14s.localdomain (c-73-69-212-193.hsd1.nh.comcast.net. [73.69.212.193]) by smtp.gmail.com with ESMTPSA id x2-20020ae9e902000000b006a6a6f148e6sm16088474qkf.17.2022.06.30.15.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 15:47:27 -0700 (PDT) Message-ID: <0a42edcea3f98879b6e480f79cc97900b1d80732.camel@redhat.com> Subject: Re: [PATCH v3] analyzer: add allocation size checker [PR105900] From: David Malcolm To: Tim Lange Cc: gcc@gcc.gnu.org Date: Thu, 30 Jun 2022 18:47:27 -0400 In-Reply-To: <20220630221153.49510-1-mail@tim-lange.me> References: <20220630221153.49510-1-mail@tim-lange.me> User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, BODY_8BITS, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jun 2022 22:47:32 -0000 On Fri, 2022-07-01 at 00:11 +0200, Tim Lange wrote: > Hi, > > here's the updated patch that should address all the comments from the > v2. > > - Tim > > This patch adds an checker that warns about code paths in which a > buffer is > assigned to a incompatible type, i.e. when the allocated buffer size is > not a > multiple of the pointee's size. > > 2022-07-30  Tim Lange  > > gcc/analyzer/ChangeLog: > >         PR analyzer/105900 >         * analyzer.opt: Added Wanalyzer-allocation-size. >         * checker-path.cc (region_creation_event::get_desc): Added call > to new >         virtual function > pending_diagnostic::describe_region_creation_event. >         * checker-path.h: Added region_creation_event::get_desc. >         * diagnostic-manager.cc > (diagnostic_manager::add_event_on_final_node): >         New function. >         * diagnostic-manager.h: >         Added diagnostic_manager::add_event_on_final_node. >         * pending-diagnostic.h (struct region_creation): New event_desc > struct. >         (pending_diagnostic::describe_region_creation_event): Added > virtual >         function to overwrite description of a region creation. >         * region-model.cc (class dubious_allocation_size): New class. >         (capacity_compatible_with_type): New helper function. >         (class size_visitor): New class. >         (struct_or_union_with_inheritance_p): New helper function. >         (is_any_cast_p): New helper function. >         (region_model::check_region_size): New function. >         (region_model::set_value): Added call to >         region_model::check_region_size. >         * region-model.h (class region_model): New function > check_region_size. >         * svalue.cc (region_svalue::accept): Changed to post-order > traversal. >         (initial_svalue::accept): Likewise. >         (unaryop_svalue::accept): Likewise. >         (binop_svalue::accept): Likewise. >         (sub_svalue::accept): Likewise. >         (repeated_svalue::accept): Likewise. >         (bits_within_svalue::accept): Likewise. >         (widening_svalue::accept): Likewise. >         (unmergeable_svalue::accept): Likewise. >         (compound_svalue::accept): Likewise. >         (conjured_svalue::accept): Likewise. >         (asm_output_svalue::accept): Likewise. >         (const_fn_result_svalue::accept): Likewise. > > gcc/ChangeLog: > >         PR analyzer/105900 >         * doc/invoke.texi: Added Wanalyzer-allocation-size. > > gcc/testsuite/ChangeLog: > >         PR analyzer/105900 > * gcc.dg/analyzer/pr96639.c: Changed buffer size to omit warning. >         * gcc.dg/analyzer/allocation-size-1.c: New test. >         * gcc.dg/analyzer/allocation-size-2.c: New test. >         * gcc.dg/analyzer/allocation-size-3.c: New test. >         * gcc.dg/analyzer/allocation-size-4.c: New test. >         * gcc.dg/analyzer/allocation-size-5.c: New test. > > Signed-off-by: Tim Lange Thanks for the v3 patch. Content-wise, the v3 patch looks ready to me, though there's something weird with the formatting of the ChangeLog entry for pr96639.c in the commit message - does the patch pass: ./contrib/gcc-changelog/git_check_commit.py HEAD ? (this script gets run server-side on our git repository, and it won't let you push a patch unless the script passes) You didn't specify to what extent you've tested it. If you've successfully bootstrapped gcc with this patch applied, and run the test suite with no regressions, then this is OK to push to trunk. [...snip...] Thanks Dave