From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc2a.google.com (mail-oo1-xc2a.google.com [IPv6:2607:f8b0:4864:20::c2a]) by sourceware.org (Postfix) with ESMTPS id 537A33858017 for ; Fri, 4 Aug 2023 07:38:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 537A33858017 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-oo1-xc2a.google.com with SMTP id 006d021491bc7-56c87f89178so1233693eaf.1 for ; Fri, 04 Aug 2023 00:38:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1691134731; x=1691739531; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=XhJENi/m7CkXJZzrDrpbVhhrqJN9/z3q3TODAGlCKBo=; b=CShIy/HnStGg1b239sgtG/wxdhDAfXaGtlEAmRn+fIh06ykTVQ7rqtUSru4TVRyh3K Wj3KbEEb5RsnsFtGZIQyOrmPjwLhNynXImkJcLavWX7oI+X0JRNljRC5z2Pk04jXNyoB j6g1wYgev6XWBZhRxRMDysW6SevcPXkzDkzyY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691134731; x=1691739531; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=XhJENi/m7CkXJZzrDrpbVhhrqJN9/z3q3TODAGlCKBo=; b=UPFPZUZ7ksIj1MvZ/6lwBOzhlD9ksQZRruQJcRbkrNc5R16nTXeo4ggCSkTqX4sWzE 9evkhZB9wvogY6qwVFlqIx+kWhkKcBJMzHThifPZE81YptsG7T+kOy85Dyh32ABh01E3 zFrd6jkTDIbIgo2lWvjfJcc0AQXavdpaq8DUqyxy7Zrx55NkkADaxpOb4yShie3IROyN NlJ6jAXx/Ya6kex5Sqr3MKDsCtrtKHjVZi20GjD4ZBe0eS7O5x74VIN98bY3GYxPs9hy IslBzyEG9J2/8w0GAgBvqWy+ki3WMHRMKAWlkzvOa6qkEpCcyYbuZKiKKOU77d140kXO GJdA== X-Gm-Message-State: AOJu0YzlEL1ohXnkXWuV23bxBqFVkIllYMUn7aYOQ5N+l5lAF6gruygh Lto1m7igzB+qNrlpkicecyXibOfqeLTpBqp17ik= X-Google-Smtp-Source: AGHT+IG+U6z6CrQi7R5+wCHPpvLsg4Aex/Nq9KKydAg7bVRyAi0IIgDJQHdDXf2RnWvD2NTvhc/s1w== X-Received: by 2002:aca:b04:0:b0:3a7:470a:e702 with SMTP id 4-20020aca0b04000000b003a7470ae702mr1019875oil.16.1691134731205; Fri, 04 Aug 2023 00:38:51 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id v5-20020a17090a898500b00265c9062f94sm972658pjn.21.2023.08.04.00.38.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 00:38:50 -0700 (PDT) Date: Fri, 4 Aug 2023 00:38:49 -0700 From: Kees Cook To: Qing Zhao Cc: Siddhesh Poyarekar , Kees Cook , jakub Jelinek , Martin Uecker , Qing Zhao via Gcc-patches Subject: Re: One question on the source code of tree-object-size.cc Message-ID: <202308040037.AC76C0024@keescook> References: <202308011549.DFC402C@keescook> <46A77E9B-7A6B-41B3-95B0-A6752671B09C@oracle.com> <7602f2ad-a4ab-0104-1679-bde15b7284a8@gotplt.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no 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 Thu, Aug 03, 2023 at 09:31:24PM +0000, Qing Zhao wrote: > So, the basic question is: > > Given the following: > > struct fix { > int others; > int array[10]; > } > > extern struct fix * alloc_buf (); > > int main () > { > struct fix *p = alloc_buf (); > __builtin_object_size(p->array,0) == ? > } > > Given p->array, can the compiler determine that p points to an object that has TYPE struct fix? > > If the answer is YES, then the current__builtin_object_size algorithm can be improved to determine __builtin_object_size(p->array, 0) with the TYPE of the struct fix. I think it is fine to leave __bos(..., 0) as-is. From the Linux kernel's use of __bos, we are almost exclusively only interesting the mode 1, not node 0. :) -- Kees Cook