From patchwork Mon Jan 8 09:22:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 1883583 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=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=iW77Prvh; 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 4T7pZ3173mz1yP7 for ; Mon, 8 Jan 2024 20:25:14 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9759B3858293 for ; Mon, 8 Jan 2024 09:25:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 93F943858281; Mon, 8 Jan 2024 09:24:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 93F943858281 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 93F943858281 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704705888; cv=none; b=S88JYatQ6JI+yOdRWwX35de2CaPjDVDBzg3monktapaXj+ogy713+E+v1NLsZGxmf8qeRSLf4GqH3V2+Yz5MsHF0N916Ghc2uRSNZwyvwtUlDnhhxvV9OAnbUaHS3cR+CpW6z7EK1Un2CJF4PQZM/UD/0pjreKuIPynoQeBu2+Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704705888; c=relaxed/simple; bh=mqrRenqDqRnKpyZ+P2t/CwQVgPKNn0lfePGfaCJO6v4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=sBAG6B/QR+TNPe9EQgG/JROHIs8EAa3zMco28m6i3SN1ub1u28fAgDbatHMmxuS5AE9pDFO2r09ir+YmDxa13MyAi+cUnItC+WI4gSXau9oqcN0X36J/ZZajm9Vop+fAxN5eBCYJdR35SVdY+ohyLv4ZcGiVr3osLQvQAB/Z6yY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4088aGn7005969; Mon, 8 Jan 2024 09:24:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=SxstiklwEnhk54JV6W7Nyi/fSPWQ6GO+lhdIFsxb25Q=; b=iW77PrvhOKuNZRT+mRB7VSQ+Z08Or5eeyHbWu5kO0qAlLoXHda4mdirRd/8W6aZ3eSnV mOWJTAwOXR/0h/OarQ9o5/5iidORfoUuoBDI/3a1r6tbhtSENxA8m3bAUJjIhTzIrBJv WBnM4NIoPQFURJwZVhYrMC5d1rmelVTKzP9tRPzxJRQbwyNxqEkO17evS7UR3AGWEcGR lkfQm65yoeSAmIDTwC9NtJ6xDEH3Mb1eN9fwuh37UYBLaalosqusia5TxlBa1T7zlDCn /Q92ILpd4vZE2BSC6iWC8IKOyrrkWNeUdS/zyt4fE+HPGDs0L4VTYC5ohozmWbippTD7 SA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vfy0yfr7r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Jan 2024 09:24:45 +0000 Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4088jW7Y018190; Mon, 8 Jan 2024 09:24:45 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vfy0yfr7e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Jan 2024 09:24:45 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 4088q2a6022819; Mon, 8 Jan 2024 09:24:44 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3vfhjy76wq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Jan 2024 09:24:44 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4089Ofe944499664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 8 Jan 2024 09:24:41 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A79462004B; Mon, 8 Jan 2024 09:24:38 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 514EE20040; Mon, 8 Jan 2024 09:24:38 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.171.89.106]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 8 Jan 2024 09:24:38 +0000 (GMT) From: Ilya Leoshkevich To: Jakub Jelinek Cc: Andreas Krebbel , gcc-patches@gcc.gnu.org, Stefan Schulze Frielinghaus , Ilya Leoshkevich Subject: [PATCH] asan: Do not call asan_function_start () without the current function [PR113251] Date: Mon, 8 Jan 2024 10:22:57 +0100 Message-ID: <20240108092434.554918-1-iii@linux.ibm.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: K3_mrXRubnYp-_PDRUr-_vRinFJxlZIT X-Proofpoint-GUID: 2-WghHTvuTUqnALJsrwXQP2WKi75msdf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-08_02,2024-01-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 mlxscore=0 spamscore=0 mlxlogscore=971 phishscore=0 adultscore=0 bulkscore=0 clxscore=1015 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401080079 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, 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 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 Bootstrap and regtest running on x86_64-redhat-linux, ppc64le-redhat-linux and s390x-redhat-linux. Ok for trunk when successful? Using ASAN on i686-linux with -fPIC causes an ICE, because when pc_thunks are generated, there is no current function anymore, but asan_function_start () expects one. Fix by not calling asan_function_start () without one. A narrower fix would be to temporarily disable ASAN around pc_thunk generation. However, the issue looks generic enough, and may affect less often tested configurations, so go for a broader fix. Fixes: e66dc37b299c ("asan: Align .LASANPC on function boundary") Suggested-by: Jakub Jelinek Signed-off-by: Ilya Leoshkevich gcc/ChangeLog: PR sanitizer/113251 * varasm.cc (assemble_function_label_raw): Do not call asan_function_start () without the current function. --- gcc/varasm.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/varasm.cc b/gcc/varasm.cc index 25c1e05628d..1a869ae458a 100644 --- a/gcc/varasm.cc +++ b/gcc/varasm.cc @@ -1845,7 +1845,9 @@ assemble_function_label_raw (FILE *file, const char *name) ASM_OUTPUT_LABEL (file, name); if ((flag_sanitize & SANITIZE_ADDRESS) /* Notify ASAN only about the first function label. */ - && (in_cold_section_p == first_function_block_is_cold)) + && (in_cold_section_p == first_function_block_is_cold) + /* Do not notify ASAN when called from, e.g., code_end (). */ + && cfun) asan_function_start (); }