From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bee.birch.relay.mailchannels.net (bee.birch.relay.mailchannels.net [23.83.209.14]) by sourceware.org (Postfix) with ESMTPS id 1635E3858D1E for ; Thu, 3 Aug 2023 17:19:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1635E3858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id AA127540CE7; Thu, 3 Aug 2023 17:19:21 +0000 (UTC) Received: from pdx1-sub0-mail-a205.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 38AC3540A2B; Thu, 3 Aug 2023 17:19:21 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1691083161; a=rsa-sha256; cv=none; b=hVxATiiV3Vuk20QZxrXVGbixKJiAvWWOesC7SgESFu3ssE7GqXYfcBY6QWHGRame1rTG3R QciiYdykRzYMgDEKX5E6MXOBoHjZ94MuXM2/rh+Ve3Gi3mZvVtW68GglPgfSYeTjq/UvWC 1d9o4TulQvcVyFqySZsGhArCSGITL7RU7nu91fnf8tVUarwAPMHavWClVridZBy5r7kDxP vl/xeg99zTdwa+6peZyX90Udi+AgHcNs2W38giGb/UhUIHO074NJ+GqfLspvHgq/GGOL5Q Be4JeoEGGidzEGqYVUT75tATx1fvqUT2AOmkoghQ4oALYFVcdMUz18y4MiTejw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1691083161; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CgVQEj1BWpcQz/epoc6e/yplArz9ql35X2OpHZDak7c=; b=SzIMWti1v10mphsR3Ob7BdHAX5PtCCn5F5zWchXvJ9IriWkSczOFFJeE0cowsamrzEJIgP 8/rD+aOQD5B60WmUK1ySXInwK+u8mddjt/0s5X4Yow7dyM7pB84kOgO4O4UdjxGNmIlIMP +Z8tS80iwr6NM/fxWEKLE1TxhzR9TSHbbo63E5UHf9oZ+NAfb0/lWP5bM+aeLv7eTp3oOx zRwxRVwq0LjTtoQkGr4clJwUgEtOoPUEeeqf8cSKZdUWO6qAeMSJcwkd9jAN4VA7eFTEul N3LwJcshyKLm/MjyYDwO4KTwUMgFBbHmLfw8slson6QFaT76a0tW2Qhiuk1bzQ== ARC-Authentication-Results: i=1; rspamd-6588fd49b-c6hlg; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Spicy-Blushing: 0bcd784421fb1987_1691083161488_4050003965 X-MC-Loop-Signature: 1691083161488:1293743264 X-MC-Ingress-Time: 1691083161488 Received: from pdx1-sub0-mail-a205.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.121.23.53 (trex/6.9.1); Thu, 03 Aug 2023 17:19:21 +0000 Received: from [192.168.2.12] (bras-vprn-toroon4834w-lp130-02-142-113-138-184.dsl.bell.ca [142.113.138.184]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a205.dreamhost.com (Postfix) with ESMTPSA id 4RGwZ050Vrz1Z; Thu, 3 Aug 2023 10:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1691083161; bh=CgVQEj1BWpcQz/epoc6e/yplArz9ql35X2OpHZDak7c=; h=Date:Subject:To:Cc:From:Content-Type:Content-Transfer-Encoding; b=WMbW6oT893ba63QHQ3M/t2XLaqLGAqNz3Gg5gJex/QiUG4QbE9WJJ+OwXO36A3v/E Y0CsoTn8V8AZLKHBJbE719jhtEwAmE8iq9UM/a8vXECNI4EriG8Pd52Ksh09da+EZm 5Yn+d2uxyLLgF6g44sLIeQGJ8QEuEpgOPCQjj86k0jcY4+hI3ZYuW7s+Dcgx2DFjst NJAW6FHFQr+VwKoUr9XmkT3Y1ZBU9d0+j+JXvvlB6oAHxI7vlyMvW6KlikyrYf3LvW Rui014A6gg+SduuWcO9vi6GGIWzbi4w+iQLMo7Kcy8qpkBI8pElCsJDVKRMIBiA9aY iCrxipjp08kIw== Message-ID: Date: Thu, 3 Aug 2023 13:19:19 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: One question on the source code of tree-object-size.cc Content-Language: en-US To: Qing Zhao Cc: Kees Cook , jakub Jelinek , Qing Zhao via Gcc-patches References: <052CB546-4787-48A9-8B87-BA909DA60388@oracle.com> <202308011549.DFC402C@keescook> <46A77E9B-7A6B-41B3-95B0-A6752671B09C@oracle.com> <7602f2ad-a4ab-0104-1679-bde15b7284a8@gotplt.org> From: Siddhesh Poyarekar In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3030.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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 2023-08-03 12:43, Qing Zhao wrote: >> Surely we could emit that for __bdos(q->array, 0) though, couldn't we? > > For __bdos(q->array, 0), we only have the access info for the sub-object q->array, we can surely decide the size of the sub-object q->array, but we still cannot > decide the whole object that is pointed by q (the same reason as above), right? It's tricky, I mean we could assume p to be a valid object due to the dereference and hence assume that q->foo is also valid and that there's at least sizeof(*q) + q->foo * sizeof (q->array) bytes available. The question then is whether q could be pointing to an element of an array of `struct annotated`. Could we ever have a valid array of such structs that have a flex array at the end? Wouldn't it always be a single object? In fact for all pointers to such structs with a flex array at the end, could we always assume that it is a single object and never part of an array, and hence return sizeof()? Thanks, Sid