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.129.124]) by sourceware.org (Postfix) with ESMTPS id EF0C93849ACB for ; Wed, 10 Apr 2024 20:56:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF0C93849ACB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EF0C93849ACB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712782579; cv=none; b=FvtSLsoN2AhevxUf+IdUZy6olvv7Aza83Y8x4A27CZ5NgGyC8iWYBbLeT1SerkB9wFYHn1uXMmeDGF4jnLAXRv+uwzpk39A9YJ0n/IICQoc+s0AawHUtfpYf71WG8QyKWJSHru77whVHAw8dAvXLNV6D1PlMLhtqpc8FuQllqsE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712782579; c=relaxed/simple; bh=emAFaDnDoKEOPHVLM6615+7typhg5ntIJ7uvqGaHYsQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=NarSeDq6eD/+M98UAFHalsCaQafCGLKl9ZB2o/fSuzy8cf0lG6Pc8jzVyRepZGhPzDyQpysXgKSWWvcjryHe/rkDMYNScN7trb3Az3h7XauzkrjPxw0/IqPdSP3o0rzCUkDu2ppjsJ0fe9MrETLGy7pgaC0FGDsDcFO4lV0smyE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712782569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=njMuu6yQqexMDqpDFEllww0ifhXAoBv6py0rENEhmy8=; b=IEWxZvNMfqeB0IRenXMUwrykP/uF9mkZoy1YHjvGdrSzso6tcGQgHLsyh6VIK7s3PgIapD aSkI40/rrowtp5NPz21m9o6c3k+aUG+3uyEdDLt4XHF04+L/Xv0GzIw9YxFXV5xfZmkKs5 Ol1gzVCuB/eiCv1hB2WmFyfpkCcZY6o= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-629-V0IF6z-0N-q4OQYU-PI25w-1; Wed, 10 Apr 2024 16:56:05 -0400 X-MC-Unique: V0IF6z-0N-q4OQYU-PI25w-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 86B6129AA3BA for ; Wed, 10 Apr 2024 20:56:05 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.22.33.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EADD492BC6; Wed, 10 Apr 2024 20:56:05 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [pushed] analyzer: show size in SARIF property bag for -Wanalyzer-tainted-allocation-size Date: Wed, 10 Apr 2024 16:56:03 -0400 Message-Id: <20240410205603.335731-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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: Tested lightly by hand. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Successful run of analyzer integration tests on x86_64-pc-linux-gnu. Pushed to trunk as r14-9898-g115d5c6b009456. gcc/analyzer/ChangeLog: * sm-taint.cc (tainted_allocation_size::tainted_allocation_size): Add "size_in_bytes" param. (tainted_allocation_size::maybe_add_sarif_properties): New. (tainted_allocation_size::m_size_in_bytes): New field. (region_model::check_dynamic_size_for_taint): Pass size_in_bytes to tainted_allocation_size ctor. Signed-off-by: David Malcolm --- gcc/analyzer/sm-taint.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gcc/analyzer/sm-taint.cc b/gcc/analyzer/sm-taint.cc index 1d1e208fdf49..a9c6d4db43f4 100644 --- a/gcc/analyzer/sm-taint.cc +++ b/gcc/analyzer/sm-taint.cc @@ -645,8 +645,10 @@ class tainted_allocation_size : public taint_diagnostic { public: tainted_allocation_size (const taint_state_machine &sm, tree arg, + const svalue *size_in_bytes, enum bounds has_bounds, enum memory_space mem_space) : taint_diagnostic (sm, arg, has_bounds), + m_size_in_bytes (size_in_bytes), m_mem_space (mem_space) { } @@ -781,7 +783,18 @@ public: } } + void maybe_add_sarif_properties (sarif_object &result_obj) + const final override + { + taint_diagnostic::maybe_add_sarif_properties (result_obj); + sarif_property_bag &props = result_obj.get_or_create_properties (); +#define PROPERTY_PREFIX "gcc/analyzer/tainted_allocation_size/" + props.set (PROPERTY_PREFIX "size_in_bytes", m_size_in_bytes->to_json ()); +#undef PROPERTY_PREFIX + } + private: + const svalue *m_size_in_bytes; enum memory_space m_mem_space; }; @@ -1678,7 +1691,7 @@ region_model::check_dynamic_size_for_taint (enum memory_space mem_space, { tree arg = get_representative_tree (size_in_bytes); ctxt->warn (make_unique - (taint_sm, arg, b, mem_space)); + (taint_sm, arg, size_in_bytes, b, mem_space)); } } -- 2.26.3