From patchwork Thu Nov 7 18:08:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Faust X-Patchwork-Id: 2008119 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2023-11-20 header.b=Jp2fT3uf; dkim=pass (1024-bit key; unprotected) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-oracle-onmicrosoft-com header.b=tcMwZQSW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XkqqC58T1z1xyW for ; Fri, 8 Nov 2024 05:09:59 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9619D3858420 for ; Thu, 7 Nov 2024 18:09:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id 273EC3858D20 for ; Thu, 7 Nov 2024 18:09:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 273EC3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 273EC3858D20 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1731002960; cv=pass; b=i5GwkNB0nNijVUFaFakv1xPa4vsssboA0EQSUqXuiN0RH+h/NvcpccpR49Zr5Bt/QQjMgdplFMFmWHHVqHjoeo9jBrTummQ2/2v/r1cicK6u2wqTmNtNUle7ucMY5A20k0yEK2X50iIaQhkxmj9YoL0ERHYW0lFDNzBbNSYJq6A= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1731002960; c=relaxed/simple; bh=+QDHvgGrHKbp6z6OxtDcfa6Bjax8G+eU9+eK+jBqsdo=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=vuKnn/Q3IVdY+mI6YrUHFxNlnvxB62e0fLIypT2/ibpyBGT+KwbO8niokxlD2Xh2ijsSrpTZrdj3s/F5yavhtdk9lRbsOoSM7ik0S4IywA16IOIvrClqGjd/BibE2Z+Qv0xEEnrknQrquVJUV6VRlJuZjPuX44hPljGeSMIWntk= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4A7HBWMv013481 for ; Thu, 7 Nov 2024 18:09:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=corp-2023-11-20; bh=h5iXYdowGl3Q+OPC oQqY2/GP6ooUCkBwBZ9KxAfju+8=; b=Jp2fT3ufYBfBhPX2VOWXtLsHh5V6I1oL eVV+ttwYgDms7Y4TTz0GTEinar10xmW3pGZ5ORnV83TZIPP6dU4qsiIgKK4MI9jh 6QK9Mg3283KFSP4SUjA0xuUrdKTAGJNyfPfDoD1hJJUgCcVqaEu+cJuI/BUm0QE7 IeMV1zZIbfr+ePNSR2eTGM+Zcd9d9vvYqe4p29mJA4DMfff2D8Wu2w5PDAL4o9X4 W40Wi+k4EodBWfsz/W9Ob8ctB7WLtLHMdzuGRBJo4AdcrUj6kIIVOxsQsGOd2J13 qcKASmH72uACkXq0peeq7SCQruGFQ98pZ3/aGbP3TWKzUxo5i5Tstw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42nbpsu7hm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 07 Nov 2024 18:09:12 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4A7H6o1V009712 for ; Thu, 7 Nov 2024 18:09:11 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2174.outbound.protection.outlook.com [104.47.56.174]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42nahgqmbf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 07 Nov 2024 18:09:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aDyEHNud7lRw38m7O+/ukvvM4SrBPODJdSNN2vbDwnD3JC4kFv8qUdIQEGvN8RynYuUFmMEQRY6Wm9D2zJHXoMMLnB/T99/AuM8bKgXFhueV1K8+aV8rYLgPs1jVrm66xpDtPgVJ/4W4iPucAZO444k8FR8vevWCWrOmzSoklH593m66hT6XcL/lCDKJeaZR5InRSuGr4Xf5APMwY6WAvXbiOp3MG2cx3KFRnl83Z7d4TnlvKX/yfB1EJrEFg9hnOC8eUTaseJDBx1zbBAtB1oyVPG1W2kR4AWOfAoJcVQz/ZgflIY2wny/+V+URKFLwJgKU8R5NMRGr3+8zoxoaTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=h5iXYdowGl3Q+OPCoQqY2/GP6ooUCkBwBZ9KxAfju+8=; b=ZY1fw6OT/Wwexb4Hc9x8QbWPwUsYSTWplm0Gs1wjN1xDzyxrb2HhQHUgDq3aqA7mTMreEYn7bwYMldfIsm4PyPLcXBEV73IZ2xXh0Waj00IpdvVJN0i1V0zlzIRyM/kYOvgND+GXGYa4cKdQa1rpx1HE/GNiijSDyL/TY9Il2YiF505EXpHPORWY3Y24mcMcRKS54Ehx6C+a4lDT6hvMjB13OE3tMAY5USSRVTLifrhvineW39l9/Od/WoUIoGyxMS42UCS7rktTOp4L0XfmWEqCo0jY9gGJlxcL9uzHsF0/mwLaD7eS9d5fpn+pwTfzB2vp4BhW8u2S5FrWeNwKQg== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=h5iXYdowGl3Q+OPCoQqY2/GP6ooUCkBwBZ9KxAfju+8=; b=tcMwZQSWyoC3/3wFpe6k6kIFQZWu4NakR/Rg4NprhKt3XyqB8EvnjT1Uvxl52OgWEq4ApYho5PsEUiYS0WR1R5JohZm2GN98CosNIuZnti8/5otBKT/HhSinFWnr/mCoauGj5GbZ8V2SGCOSA0ZXaLRvZowaCD0UmW7kebZfXHk= Received: from IA0PR10MB7622.namprd10.prod.outlook.com (2603:10b6:208:483::19) by PH0PR10MB4503.namprd10.prod.outlook.com (2603:10b6:510:3a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.21; Thu, 7 Nov 2024 18:09:08 +0000 Received: from IA0PR10MB7622.namprd10.prod.outlook.com ([fe80::2a07:dfe3:d6e0:abdb]) by IA0PR10MB7622.namprd10.prod.outlook.com ([fe80::2a07:dfe3:d6e0:abdb%5]) with mapi id 15.20.8137.018; Thu, 7 Nov 2024 18:09:08 +0000 From: David Faust To: gcc-patches@gcc.gnu.org Cc: jose.marchesi@oracle.com Subject: [PATCH] bpf: avoid possible null deref in btf_ext_output [PR target/117447] Date: Thu, 7 Nov 2024 10:08:59 -0800 Message-ID: <20241107180859.51740-1-david.faust@oracle.com> X-Mailer: git-send-email 2.45.2 X-ClientProxiedBy: MW4P220CA0023.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::28) To IA0PR10MB7622.namprd10.prod.outlook.com (2603:10b6:208:483::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA0PR10MB7622:EE_|PH0PR10MB4503:EE_ X-MS-Office365-Filtering-Correlation-Id: 00fcde77-dceb-4b7f-3dd5-08dcff57462d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: 08deuft9eIFYewQY3BEi2+s9iPCFkhjLt5cb+vkrm4IhSZAEIw0Jp3MnpV9Q17ufXhy6vcd+InxJyM7SOM2IwqriP6+8/9mcBWGo2tPAYkR+PTfepkC/zDHpE5YxTYOJCj7OTqbk4uQb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dJVtPhjKDesC0OK+nzYNwmQ3ytGxHQPPZGBRvePF2Tt4lWd2Y/OCSl0HpDt4kSrQn2CQdLTO8I+wJy2lc4lT4BUnCMe X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:IA0PR10MB7622.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(366016)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1aFnPMAl0hwMyd7S6S4Bt5UPCKWVKaD2gWUULXdzHWHaFt7P/42SkbikkWdhK88sq1wTEQCDRAJdnZqCh3gYhI2D/wKNVY6ObvCiLFWMN9ZvCW6ztEQmFkH5K0RbUrDvH9loeJ2Z677i6t3kNdfcVHvpE40ptu9MnRAXo0oZWGGXpXLrsGF7M1fctgHUL/7ALNHCj5PCYUFHDdAN4y1j70++NFiVgeoO0R6rqtjLZH3LKFdstqhl2Rymp7Ni70+tv6O+FqM4Lnsy/29hFl3qnWjoA3Op9QtiLngzw4vSqZoCNzHmFFgsQPA5pB2bfMX2GTP5pHhfpPjapWqEqoumvuPL+5+eUccnIwpRp7x1Yr/WxG77pblhS+F83Q7N/S8dT78kTtFJw8giEJeBgcg+bq3rJ5Hpm71tcXTvsTpRf3bCp89aKJhYwU937/LGKZr7dfMdWWW1aHxy+AHr0rhdslNGfWGlI5k7AJt678zi9Vc9NLoQlCcyiXvwJwHThtqJgv5JRZsDl/Ct8OsocJphXFY+RLuckrdG5OBhb0C5L7Vsvf0+iLuseZv8W864+gfZjE7dcC4puXSJiLhmPGCEYivrj1+yAHj9EtZLbqXDyF5OI2zMnTkUFcJ7GV33aoTDIYzrsGnAnTvLKIqgtRMRoCUQONow4vJbJoNqDwTvwBCkCNAseJu8EHmhLMWDpyMich0EUsainwV/qSHLpJsZMgaIroEnX4W3DCkQ52DnvFyZowBcGuWmGIxh/Q+pwTYgfURReVfDVepdbSbwhUKtBfExkzTgjUTkSegi7v3gdMT8gpe+8XYwqanLb+WNO6dEv/JRerCoCrZVQPnsOva07ivUksvtGada4atJKrY8rnSZ45ifgmhmKv8CAo+xVBcN8rHV4mmuD5qBbQ5ATJd4BY/W88lwhXG+vKhsn8TUZmulKjeI2w3Fh0z4qICloFSVIsQ4S7wR/5jBr+QAdyFfUSFktHnGeNcZs2ZTw52GM1BU/gjKO4Ov1psqko0DObzD8XwKZ08w4CfDMY4Ou3e+RyqZfwmlIAHnNItgnUOjQ+CrKniHExUeOywWCxNR7BovSFrz/q5vCpozNMRpJcsIp0gSKcTRefUkBjmwBhjsAT8xTVPfBquThYxvgwQSaTHnXSet0wLjiRhZoZLVGa3smQebU10/7PhnWktsUbBwW5a580U5P8ejshAlMUsOj8Sx05uaKPAE+lR9EvT1QvgFBYE6kelv5Z2aO9yOZtAR88E1owqY6dXfMmAUhUaMxNpk6c/FWfac/X8v8+Mf5flgbq8EcIkwttYqrtewiiUvJfHam6CaSs7ITSW4JUfycWnYDEtZ7G3Pg8c5d+VguLZhnw1EH3mTj5vaRsZ6BxNImvGJHF9ISLtSO23+wUdkJZxbDt8ypTNa6K0idThBFbQiHzxZXd7+7RFzE67pydBAepQBgYTd2FADuSA+h6GbK15EA8zHSnUswf7KzFeXndndHFQCEzQRjTxH4WpL7u1r/44N3HMfCaiyMrBPkgYsKDHsaZGgMvz+eHsIQXEebY2AiTRixEsccBE3lDdH0spOhAyQJdf4UKiXhj4EBLmgDawvgXgKOB+dpUrPnxAZoHeX8w== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 0flW+EBoaW4wNJa6jROtBPvW2RWsJHWrrE+lXdscW4NXtmJx22SFXY0Ym/ko5zpAVwjNEuE08pQwiSzVf7GJ19gFlaA6F1+Rr4YYY48Q1/ZtvDs72+fInmfGIrRFzklm7bbndVmU8qmkVYgkqJ50aVGI+sAeKbqfjz3le6KTyas15sLLojNWwB7x3b+/UYJ9b8Q+INMviR/cAIYVkLOIZINVXyOZbXkid4wFkwzaI/8nxslcOG/nYgIJRLQb5hIkzHHhSyfc/27gVMGaOh2UehJZlaua2X2yrvxXrqNoBXBbhJJOWKAhKgW4kUH7WEYd8Gbdhyp9/uliKbqBGYzCL+wLynhlN7fkDD37j3Q1U4EH3wQt0L0SXTq4lrLlcHszPZ9N4VcZE5Eb2JqEs0XtcqcdBKrGyYbH0M9qnifD3IFYgzF1SGLSZhtg5euY1MIiTh9BTAG/CwX+Zmiu6hB9U4RRQhPXEXqXtKSugMrUIXIHFsEr1fJPlNihtdNJ4F4mtXaiXP8JuBWHnkwsKB3f42zD2gS/dGs7WTZZQNWF5TtwiqfBlLsVyu+Qhj0G54/ZuN92lHA4sSzEjGpeXw0rIB29JSSUze+z8b89BgSz158= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00fcde77-dceb-4b7f-3dd5-08dcff57462d X-MS-Exchange-CrossTenant-AuthSource: IA0PR10MB7622.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 18:09:08.5388 (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: NwXwpdMuwbNzud1tTfQ6svU2hYmzXvbXG2HJzihPw3Izw1HB8LgrAnwXuT45a2C72RFWkPXuHG+CqHsUse9dzg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4503 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-07_08,2024-11-07_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 mlxlogscore=981 mlxscore=0 suspectscore=0 bulkscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411070142 X-Proofpoint-ORIG-GUID: SN_I2Jj7s_LPGtZyM5dZZhgcp3-z9mFB X-Proofpoint-GUID: SN_I2Jj7s_LPGtZyM5dZZhgcp3-z9mFB X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org The BPF-specific .BTF.ext section is always generated for BPF programs if -gbtf is specified, and generating it requires BTF information and assumes that the BTF info has already been generated. Compiling non-C languages to BPF is not supported, nor is generating CTF/BTF for non-C. But, compiling another language like C++ to BPF with -gbtf specified meant that we would try to generate the .BTF.ext section anyway, and then ICE because no BTF information was available. Add a check to bail out of btf_ext_output if the TU CTFC does not exist, meaning no BTF info is available. Tested on x86_64-linux-gnu host for bpf-unknown-none. gcc/ PR target/117447 * config/bpf/btfext-out.cc (btf_ext_output): Bail if TU CTFC is null. --- gcc/config/bpf/btfext-out.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/config/bpf/btfext-out.cc b/gcc/config/bpf/btfext-out.cc index ca6241aa52e..760b2b59ff6 100644 --- a/gcc/config/bpf/btfext-out.cc +++ b/gcc/config/bpf/btfext-out.cc @@ -611,6 +611,9 @@ btf_ext_init (void) void btf_ext_output (void) { + if (!ctf_get_tu_ctfc ()) + return; + output_btfext_header (); output_btfext_func_info (btf_ext); if (TARGET_BPF_CORE)