From patchwork Thu Jun 13 18:54:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 92107 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 81B52388267E for ; Thu, 13 Jun 2024 18:56:54 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id E638F3882059 for ; Thu, 13 Jun 2024 18:54:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E638F3882059 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 E638F3882059 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1718304888; cv=pass; b=KLdAT7XJDZyWf/TO8/8TzcSDLisXX0QTWmdZ9a6dTOpBOiN9EGCdx1e+OMaHt1GhBXQdu7/e9cJozFexmmqwnC5MUumhHl5Gsns/uSGUvROOD6j0B0oN+POZtcZ5B/4O0qP8KuVA3XNmtYwKcJ5PNVpa2BwnxdNsoRiZCH++H0I= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1718304888; c=relaxed/simple; bh=swdExyHeGCl6Xo+JB6RqaLZoFfqfEFsW3lxO7DlvWOk=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=dUoiR6AzI0eT2eW2OiseQ7LqUAxhdjNr0fhjf1yFWiHMphEu/MgvFduoLENlnnkK3s/D85GVhUH4SClcc4hoBsNDuid9Hh8wv1tXxOH6NJg3k8ZvMlykFRNF8T+dshKeDpwVet9uddLsMxbo57RJzfd7ilJ1eIDUJ39z2CIiqlY= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45DEtTBK003182 for ; Thu, 13 Jun 2024 18:54:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=50rFjeR+8/mQvuSLJlQwI9KthR0C1HvqSPsihxWYh9M=; b= giTho2HX/D/XjQJVykVI1SL91AzYBfN+Kc+gmoDSp0Z0kHUHRBptPHht++l0tcNs xxT89W6t1UU9gHMRUXmwmNBf+LgGnW2vxj3MOoRVXwAdzCnWuwSht9+ctK0Xcpoz x9J6/VoBuUp01tDSCHrALEKd8gQR4oxxmg37BI4vd8FQjvaevDG8VQhXvAaszXAP nKNwJB8Ij1E3cXP1Id8ndKvupJyXHTV6aXeblcZ/P67SwVx6/kX6Wsk3vprR/sPH CfXOWtsC1meU4Q6YkLEQ6HQJef+P12NVBnimCd2+7z5Hf7yIUizxcJOPE4Iv0jWF OKq8tgLBgq0lH7ObhfS/Dw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ymhf1j8eu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 13 Jun 2024 18:54:45 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45DHPtQR020372 for ; Thu, 13 Jun 2024 18:54:45 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2045.outbound.protection.outlook.com [104.47.66.45]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ync91kh4p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 13 Jun 2024 18:54:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hpaR4Q+SGajaFqlLZ8QCV1gsEnEiz82TI5mygOKERXkmwqisbRpxQ4k8k/eZsctzDz/w2GmtQw+Eaa323q5HCVjAaNGlOiCCtmgwRdZgwo593J45HF4b9fHhx+IHnKuidwZvkJi+g16hnXxomDRe0y0+RN+/G+PSJTQJgyD+t5NYuSDmBSyM4LghN29VA7gzbxPJVW+RmexCbOVC8KPqoNLLPLbi0aCqQaQLEv4PpoWKBvTwFISfNirr64gd0mn4DL4Yd+A/Ubx8J7tnmS0nOXY2Eb+yHg8xWCaXHVt0BaLSNYnA6NtUrM1DDYvqRL5kUxbWe4K/EZqGB+e6epgw0A== 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=50rFjeR+8/mQvuSLJlQwI9KthR0C1HvqSPsihxWYh9M=; b=eVuMV8ojxQ8b4J3Wr5ArQ4TUv5tCsAFuwSR1ZyTOn2j3ovxGoxCrrNdMU5GNH2CGnaqGD+PRwTpLzYz3r3RNRuEJmhCkvx9S8/JyT4kAwAMLlTgAjmf0RRxk5UCnRQRnFGsDJ1MWZDwZaewNZEls+mXsocY/gEq3hC4V98JuY4c7aXsP0/NvPzCUM+LceXuIvFhkwNCaJCvZY8i2BOtVe32rx7Nt/jOn9Wp7YztQ0kdv72zzwApyqH7AbpSWmmMRA2clbS8cUkHJnAOo3h1J14w3Jo8NuaFpcYN2i+ccpAPHK7/nOmBc6CfDp5JKUjNp0/wHfhEY31s9U0ImGl3Qxg== 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=50rFjeR+8/mQvuSLJlQwI9KthR0C1HvqSPsihxWYh9M=; b=niRSEVX7WTb0r2dif9MdrDF3ZKv3xyCJ5Pd3FlIAybyrWdmh0apZtg/jJNnvXGMtKMLm9pA8koSyYiBMYMelvvgC5iHA2Vx/BJhnrGNzQPAVp2jQpybqsnaEhAGKavSpTYC/CXwNsWtP0tazyyb82SZJwtExZb/j3mJDgIT5qdc= Received: from MW4PR10MB6608.namprd10.prod.outlook.com (2603:10b6:303:22e::8) by CO1PR10MB4451.namprd10.prod.outlook.com (2603:10b6:303:96::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.20; Thu, 13 Jun 2024 18:54:43 +0000 Received: from MW4PR10MB6608.namprd10.prod.outlook.com ([fe80::b53a:ccc1:c190:c5df]) by MW4PR10MB6608.namprd10.prod.outlook.com ([fe80::b53a:ccc1:c190:c5df%6]) with mapi id 15.20.7677.024; Thu, 13 Jun 2024 18:54:43 +0000 From: Nick Alcock To: binutils@sourceware.org Cc: stephen.brennan@oracle.com Subject: [PATCH 01/11] libctf: strtab corruption when strings are added to ctf_open()ed dicts Date: Thu, 13 Jun 2024 19:54:20 +0100 Message-ID: <20240613185430.85352-2-nick.alcock@oracle.com> X-Mailer: git-send-email 2.45.1.275.g567cb0950c In-Reply-To: <20240613185430.85352-1-nick.alcock@oracle.com> References: <20240613185430.85352-1-nick.alcock@oracle.com> X-ClientProxiedBy: LO4P123CA0282.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:195::17) To MW4PR10MB6608.namprd10.prod.outlook.com (2603:10b6:303:22e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR10MB6608:EE_|CO1PR10MB4451:EE_ X-MS-Office365-Filtering-Correlation-Id: 27a31a84-6b75-4e52-9d65-08dc8bda495e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230035|376009|1800799019|366011; X-Microsoft-Antispam-Message-Info: 4sdr+ohS+bGjJqa2/eFYcGox1qDQdDecJAqYYXaKYHx436Nlexl/c/xamICZKGK8BhOqCczNGU7h8AKnDEOBYFKsAUcFY4/TCQ17EkRh0Vg4t3id7121TBUzosQvP7YmXsp6R7WLgrT96PaRCZ8Q5DbKXTZpCzrfrnJ5UPkQtDTNqDGVdM+deSJ/+aftWjs0zxgxq4XPV40OilBafZhYykskuPSl6DVS0FQ1zCAhKfuO6w3WBeyPwAaU3EJ5hfDX50CXzRgxnlndWrsRNIKsYghPyODYzmP+6zJ7gMDgZSHjZlzOS0v3G6lKbxcX2MJb82ZSNi09i2AdqH4ulRI61L2aO4db/iDGb3cpDyWHhCsD1hfYROEq5NsXqIFqP8uHLVxtG8SHdroktEbcUizDV4r1WNGRURLP1hzmAZnwZX20+3T1xRU+gDg3MKqX0ekWz34Mljn0vuFD2WTV8uNmeQ5HpgRvIMGWUNtJ5BZVOtsFV5UOASnJaVAMYyg/5JpTXf65rUflnGA6fC9tZFTI7FvTCPxTcpn2NrO3RbPs3TgmQ64OND4N9q/BxvaFoyvpDb2NV6dc9bLO8ROonTcSvu3P8RHYVyika3AbiXFoaV/jDByOUWGpWRD/1me51MkBcgmYt/lV4/T7OTmUnwWvYxKb7oz1ioWvC69KTtbv0O75aWrfUj7ioErlynuVvh7NWoW4G4wdEp3G6+xZ/BHWSSy0gp0Fzloa47pZn+8fksRp9HpN1K1fPdLxK+1VZFuSAA/app73cVsem6V2dxsTBM41NQFA6DBFwsMscOwCBm0UwECLMPzBpD1NPk6xpvH/ZBdnSdUsXbbDOXkDdEptKqjQxjRnt8GwUKtYBGf01bMkihLnUgOXUK2R9eVdFf0KEQUKUY0AUofHMsZZLIlexHHeXx9KLhI+2HWk4HYAo/eEW9y/hdgw64K5iaKaBFVx7DiaTZ564ZXL7kYwT9I3yMePDhhl0/EZYH/fC3R7uSvIYBSTCtyT7W+ouv4PZzmVkb4J+ylcIL8KiAlWMI8T75eBfKBhqK0y5jvWdg+IfRTwG1ZQsVvhbl29rWVH0oP6yDljVO8c4WLrfKVqOQAnsTZYRfqJMuMm+Sw5pUXtLffkoZuJ+Tww5tq6V+EAYRDrzZ2wijZK5m8AKi+TtJQnuE2UsN656Zhg1xve+MA3LqDEKsA7kjN6Ovz071kxVV9T2M8IKgP0sJZfWJ4WOERvt+ejxeVJR/5yEAVd1YA6DYpwA/SBdTfZLCBmr8aGybG93jU9fzcUhdsAEVSUaax+Jw7kjxY5R6Jb4Gc6+rQwabkj2sQ7bRnbYWSleRVsrhFJ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW4PR10MB6608.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230035)(376009)(1800799019)(366011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fky3KYhwW8bqS6tZAqPuIKAlE7xlzkdDCjmyIWzIc2FWZJXqkf1XqWSz2L7ZG1v8hokXxWfh04/FDrl3ILwxFRGQTYT7uFpCtogOffvZTkQMyyqfL4jgL+1a0T0Ku8MbdSNLzm2DZta3M1qJ4GXdUOTAiE9UR6G+KKCZK23ebRlcaxK4wL/zT0dWupsNRah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qI4BEs5cQiFq0Ol/QrlaZVlXuXhgsDZG/NBrxq8bABKm6Hf2gxsxciReiWyPIC+GUJqlbHZ+NpUgruxOxYW9mtUBJ3pDSinDMVSxvg8SeDvOZB85Z73wM1axB5OvEZAfwMCyKJmydO3cez4Ch0V3QKNr/l0+ExEQw933luKKbKLjM10sFyl9wQoR4NcpavfCbDTqjuvxjyG3IPd28GzVwht98EbZi2GgFGSH7OgPsgohOICUFG6n1nTTQ+t6ugy6UIhNSmDg2d+XoJfVJtkuVjVMiQNiSuSS+LowO3iAwvdCwBryY8+M8xkCLIRmfa3ne6FQUIkauDd7XpP+PmG6He22A== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 6xiew20UDYdimCDv1/39KPJq8nX6qrusADngeupQCtgnBdctIvONuB9/e6bZL9khnWFCd+zf/UDMXH7LoWkl/X8oeGYLqpuz7K0rIk/4fhE919WtXKPHChlKqkk8oVcalOAeg+LssLpdnlVi6nZMwzBdrUowXo/akmQR6d+YJrDvoZo2TkpNzFfbtyTD7qwTSbC0XhrP0uLlPpoEqWBogahZ+uNHejrRsdrWjCtI2cj70lw+vTLbP7HdYr2Wd7xJE8mYHp4Oir6xJeD3tBTMSBFZSMnA+k08/86VHOcGfFkrjj2+FcYo+qhyhcqWvcGs9/BVkggLeltuTlD8A8fcZhNzgOfzmFRNAcz2cgeg98WYMDIiD3i9CPD2ClqZS4owh7eQBOvSwWYM41OKfmD85wTodxSbEnEOJu7dTXj2YC6oIY5S/tbTCJ28yD+Pz4+k8Hps3gSPHv4koxZFFLysmKpNX3CKvozF7p9NJ13nHrOfLkM8D8VJfTUdD1FLwQr8wfdF8A5JOeG1DqenKtCl3iOadONaGVapX1jWQKhAryrN2tQVyLx5bGJiDyqOFRSXa8/DJxTfiFQpO28fiKLuNNrs+OMhCLCFiaaB1lNTwCI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27a31a84-6b75-4e52-9d65-08dc8bda495e X-MS-Exchange-CrossTenant-AuthSource: MW4PR10MB6608.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2024 18:54:43.1925 (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: tny1v76dYFgysgsUluL9j7YMGxycFHSvM14V1fdG9vuzwKpnXJwEaVIp0jBqLdeNFXi83bZvygsBGGiy/XQmKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4451 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-13_11,2024-06-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 spamscore=0 phishscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406130134 X-Proofpoint-ORIG-GUID: LVjrepUp6H7QKfMYHIUPt2Dr4fsx3YC- X-Proofpoint-GUID: LVjrepUp6H7QKfMYHIUPt2Dr4fsx3YC- X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org ctf_str_add_ref and ctf_str_add_movable_ref take a string and are supposed to return a strtab offset. These offsets are "provisional": the ref mechanism records the address of the location in which the ref is stored and modifies it when the strtab is finally written out. Provisional refs in new dicts start at 0 and go up via strlen() as new refs are added: this is fine, because the strtab is empty and none of these values will overlap any existing string offsets (since there are none). Unfortunately, when a dict is ctf_open()ed, we fail to set the initial provisional strtab offset to a higher value than any existing string offset: it starts at zero again! It's a shame that we already *have* strings at those offsets... This is all fixed up once the string is reserialized, but if you look up newly-added strings before serialization, you get corrupted partial string results from the existing ctf_open()ed dict. Observed (and thus regtested) by an upcoming test (in this patch series). Exposed by the recently-introduced series that permits modification of ctf_open()ed dicts, which has not been released anywhere. Before that, any attempt to do such things would fail with ECTF_RDONLY. libctf/ * ctf-string.c (ctf_str_create_atoms): Initialize ctf_str_prov_offset. --- libctf/ctf-string.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libctf/ctf-string.c b/libctf/ctf-string.c index 0c5bd58cdaf..2d96e45617c 100644 --- a/libctf/ctf-string.c +++ b/libctf/ctf-string.c @@ -195,6 +195,8 @@ ctf_str_create_atoms (ctf_dict_t *fp) atom->csa_offset = i; } + fp->ctf_str_prov_offset = fp->ctf_str[CTF_STRTAB_0].cts_len + 1; + return 0; oom_str_add: