From patchwork Fri Feb 24 18:35:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Qing Zhao X-Patchwork-Id: 5843 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1075453wrd; Fri, 24 Feb 2023 10:36:34 -0800 (PST) X-Google-Smtp-Source: AK7set85wUsV/MxsamvCalGUe0Fxye6IPaYM+IuPhM5nvCHayeeup6u7xtpzrMiKmrnK1YdVODMe X-Received: by 2002:a17:907:7794:b0:8a9:f870:d259 with SMTP id ky20-20020a170907779400b008a9f870d259mr22292051ejc.48.1677263794442; Fri, 24 Feb 2023 10:36:34 -0800 (PST) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id b13-20020aa7dc0d000000b004acb24be0d2si14284edu.315.2023.02.24.10.36.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 10:36:34 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yaZ14+H+; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 23D293853567 for ; Fri, 24 Feb 2023 18:36:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 23D293853567 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677263766; bh=QpER9WlpJ8R5F9gqmCViBKDsv2r+yiMJwPk+of4e34I=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=yaZ14+H+8CbtOJOZ+2A7L9oucxkTuJMk+dhsQWxEQpJ9cOyQCIY5XW61WX+RONu3j Td8fa+wGMr5mA7Aa1elj75bwIs5l40P9ef9RUN2cSf0Z/roQt40rIdN6r23Qtjsbby 0cM3sx0KUuMPgn7aUA9zxZM7w8g9fC8ChT4dMhEs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 41043385840F for ; Fri, 24 Feb 2023 18:35:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 41043385840F Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31OHibk9003680; Fri, 24 Feb 2023 18:35:15 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ntn90wtt9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Feb 2023 18:35:14 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31OHSWwg034078; Fri, 24 Feb 2023 18:35:13 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2041.outbound.protection.outlook.com [104.47.51.41]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ntn4h7gdj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Feb 2023 18:35:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AuLh782If10uNPu/KNB6fqt9uxYknhKqhTMCl/NnNa02Aw5Pbo0i7slKpipeO0BG0uysahwMs0jQOZT7PwfASh/Dk0IPvnnbSZBKJ+pB8k2kfo12WhboxUZI3QdkAKCimloD1HHHcOe2z4BpzOGIu2zNQXvwqBFgL1AdLYupNDb2zpQXVfE64fScKKMkMBUlqQVz+xFeDr64xDy0HxfCSXiYb41WTsgiwtTByHWkBvda2jwoSuoMybpSf7RyckW181/d9H2kKumbM34lMj1WFCX92E4Z4aDHrg0sTJ0/wkaffatQX3sl6LBS7WM6g07NgC9BOPkiNzMcc/2WivlEQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QpER9WlpJ8R5F9gqmCViBKDsv2r+yiMJwPk+of4e34I=; b=ifu/jbFRD7G0xv9n5BjgrgKtfGDLJEfL0Bk72UyVSgB0cL8xyZiWCXL99Y7f93Q4Co3bzSCQfkpiqh4V7hVKk8HTwQzO0tbR6ZY4SWYPOZCO8tL44NEeIfAD1T/SlRTuLY89oyE3n3cQQn9gQd2A+XOSutjUR6s9LsCigtp5FVukpatbn3t3oJ3bFnhhuUVPhGTaz6qqkqGIgl7D3MrYQvkFBWLDFJnZzfuDLEkF5o1WVP17mArbRbPz+2uzKe40fe3OpjJIogfliY5rEf0/M/rOqqXuEzMH3Hul0/5jBaatC+ZJ3kAnk1sYDRjE0qvFKQMwypSeoxNiQNZTizMFQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from CH2PR10MB4344.namprd10.prod.outlook.com (2603:10b6:610:af::19) by PH7PR10MB5856.namprd10.prod.outlook.com (2603:10b6:510:131::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.7; Fri, 24 Feb 2023 18:35:11 +0000 Received: from CH2PR10MB4344.namprd10.prod.outlook.com ([fe80::7030:ed2e:20d0:cd5b]) by CH2PR10MB4344.namprd10.prod.outlook.com ([fe80::7030:ed2e:20d0:cd5b%7]) with mapi id 15.20.6156.007; Fri, 24 Feb 2023 18:35:11 +0000 To: joseph@codesourcery.com, rguenther@suse.de Cc: siddhesh@gotplt.org, keescook@chromium.org, gcc-patches@gcc.gnu.org, Qing Zhao Subject: [V4][PATCH 0/2] Handle component_ref to a structure/union field including FAM for builtin_object_size Date: Fri, 24 Feb 2023 18:35:03 +0000 Message-Id: <20230224183505.4112295-1-qing.zhao@oracle.com> X-Mailer: git-send-email 2.31.1 X-ClientProxiedBy: AS4P251CA0010.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:5d2::12) To CH2PR10MB4344.namprd10.prod.outlook.com (2603:10b6:610:af::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR10MB4344:EE_|PH7PR10MB5856:EE_ X-MS-Office365-Filtering-Correlation-Id: 85aac40d-1eae-456d-9572-08db1695dc75 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gdo6wZl0dvO7+Pg0CcvI0ovBl5wXvhkE/RFdf/GAhtjWNanIC+IlxGxHOeBkrBS6xbXGFsDL7XNcXuz/LiIeNLe6YCU3PG2gIyEs7vmmC3ycHM7E25UPJu2ORHtAD27SoxPVnlEZx59FlsfG2J6FrUx5q2hvS4SMaG3cxlnFvOlTZtiXufsTHP/CswvaRSfkp0Jh2P2q5RnH4JBhgiVBd2opiIByvJEONZPGj7GFtkqzpHID3A/+XOhox6OfRtpsthEEbz2RudG0wBNkEBTW3GNzTL7aKpAQiDCHASkbeEmui3LflMWMudYIxPk+CDhQQrFliwFmrpZ/jUtgAiS3BCZiVGNO/04eM6yHr03PPz+ZaAPR/u8ovOTbcZBx/XXQxg/gkSCYhX//P/CeaTeEqqVjBF//2s1+BXHgi76tcmoB9jGu/EKs5QNETY8eo2PeRpmY0VOwEGwGUDo8Rl32U5caGg+1c2sXYLUKLwNt2i49Y4IeZdByxl6LSx+x1kZb1B3iUtl6mros69BYxbE5gBpnBXgkIVQ8AaEPSw/S8SvB+3BYNL0hY7RzefHFC2jXOo9s6mJIfLTYCGmfrete9B+v0cbJhpfZ3RN2729pwUgq1+iqjJavWLIbwOAEdBPnm4AiGPIpgtk9VtoV9cGI1A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR10MB4344.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(346002)(136003)(366004)(376002)(39860400002)(396003)(451199018)(186003)(38100700002)(1076003)(6666004)(6506007)(6512007)(26005)(36756003)(86362001)(478600001)(6486002)(316002)(107886003)(83380400001)(2616005)(8936002)(2906002)(44832011)(66946007)(4326008)(5660300002)(41300700001)(8676002)(66476007)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yMo1itbnhsYE2AjJssxqQwKCPbqEPsdR9EK6aSOXp6BE9yfe44oVZGJGZGTNVJqJgfMFAs7Tc4qIs7dhfnt5iVbTS9FOMn2vUfMLkmexi1ITeeXWg8qPaRheRIj1LSQmO9mbvVWgtEgkofwgj+RIuVlKmVgHEGOBLEPoz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8g7R3eJtIfJMvtsqkKI8HgrkCTLMFoiYJ/xy1KpJeSh9fcueXusNRmnNPmAg/cCpTErivJyRnxhDd8+5R9HAAq4XLbvw9JIpnjJHnqRftTtkXFaJUsPAFXcaS3XjQRooWhYWc6PHd51tT+WJd/ECMXEACnlIixIzddKpsHWSU54SAsZ9vIKUTAFbbX7TjyZR++0h8stHT9EwhfJ05hD2JznD2r/ZSrV+T4WwtWy/jl1Vqo1ERE1sKEm2c0HVj/ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85aac40d-1eae-456d-9572-08db1695dc75 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4344.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Feb 2023 18:35:11.0344 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fT/SwbUalWti5+hDTj58bGbm+hTs1D0I6Xj7DfItgYNmCZgisbJ35CuVieTWi0R0YqmE9Fj4P/ikWPOMl/OARA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5856 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-24_14,2023-02-24_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302240146 X-Proofpoint-ORIG-GUID: 2ShzBgATzh6lzzTZBmxQuJElHEu8XkAp X-Proofpoint-GUID: 2ShzBgATzh6lzzTZBmxQuJElHEu8XkAp X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Qing Zhao via Gcc-patches From: Qing Zhao Reply-To: Qing Zhao Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758738560693376056?= X-GMAIL-MSGID: =?utf-8?q?1758738560693376056?= Hi, Joseph and Richard, Could you please review this patch and let me know whether it’s ready for committing into GCC13? The fix to Bug PR101832 is an important patch for kernel security purpose. it's better to be put into GCC13. ============================= These are the 4th version of the patches for PR101832, to fix builtin_object_size to correctly handle component_ref to a structure/union field that includes a flexible array member. also includes a documentation update for the GCC extension on embedding a structure/union with flexible array member into another structure. which includes a fix to PR77650. compared to the 3rd version of the patch, the major changes are: 1. update the documentation part per Joseph's comments. compared to the 2nd version of the patch, the major changes are: 1. only include C99 flexible array member to this extension, trailing [0], [1] and [4] are all excluded. 2. for the new bit type_include_flexarray in tree_type_common, print it and also stream in/out it. 3. update testing cases. 4. more clarification on the documentation. warnings for deprecating the case when the structure with C99 FAM is embedded in the middle of another structure. 5. add a new warning option -Wgnu-variable-sized-type-not-at-end for identifing all such cases. bootstrapped and regression tested on aarch64 and x86. Okay for commit? thanks. Qing Qing Zhao (2): Handle component_ref to a structre/union field including C99 FAM [PR101832] Update documentation to clarify a GCC extension gcc/c-family/c.opt | 5 + gcc/c/c-decl.cc | 19 +++ gcc/cp/module.cc | 2 + gcc/doc/extend.texi | 48 ++++++- gcc/print-tree.cc | 5 + .../gcc.dg/builtin-object-size-pr101832.c | 134 ++++++++++++++++++ .../gcc.dg/variable-sized-type-flex-array.c | 31 ++++ gcc/tree-core.h | 4 +- gcc/tree-object-size.cc | 79 +++++++---- gcc/tree-streamer-in.cc | 1 + gcc/tree-streamer-out.cc | 1 + gcc/tree.h | 6 + 12 files changed, 305 insertions(+), 30 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/builtin-object-size-pr101832.c create mode 100644 gcc/testsuite/gcc.dg/variable-sized-type-flex-array.c