From patchwork Mon Aug 12 04:35:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 1971433 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=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=ZHwIymrH; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4Wj1t00G3Yz1ydp for ; Mon, 12 Aug 2024 14:35:50 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EDD213858C56 for ; Mon, 12 Aug 2024 04:35:47 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by sourceware.org (Postfix) with ESMTPS id C1CBA3858D20 for ; Mon, 12 Aug 2024 04:35:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C1CBA3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=quicinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C1CBA3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723437328; cv=none; b=GKbP7aAHVPN+bVhkNyFMYiSn6lIfaXJifunIx/KC6Q+uBaGI7lJTpnaHOsuQ3rFcfSoEyiToHgA20FdqxlFf3BiHa3KHk4SbcuTyztck6e6D4d5737Yp5LbgZ/lAliwJrU7rWOHa2/rugbSJs/UALdRoAmIoKp8tZvxpob4YM8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723437328; c=relaxed/simple; bh=1neuP7czrfWPv5gJ+8e+HuQIzFsgEPGnbo5HHll6um4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=mRlMLRhgtlDi8qy7A6fskeTmIlePbx0iqNHpuL4oG0KrsO339IOF1/cXJX1BwaHXnicvFpfHXa94PwTojUsEtUQ3UWOOKfWtfVy0fS6LfTxGZ1GE5ohytUFrxxLNLp20PKHizhKn3/vuS0QAqTaekBXLkCPaG8oWLj85QiovR7c= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47C2ZfbX006684 for ; Mon, 12 Aug 2024 04:35:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=T47h0qqj/vLKFqpDtXaE70 29IQmk5BSsP8LWMvj+s54=; b=ZHwIymrH2yAaSblvUz9003oylGdAlmdb0Rco0v HIYFljz7JxTmRpuZZ3l0RMRASe8IamqjcLVUnd+ARWtIiP6qhmCGb/uw/UURqmhD 4qewwnhWE49wZ6at3I5fbvMrR2P6dY2qVLH/ouaXZMTfUzL4AEEczgEaNuqQrtlK j3xSoar4g+0bIj8wT+zWnYLrLnC3gtLHEMJhuQQmW0XzMDtxo/R1jpxPKuE3F4qr RtK+J8Htgb72T/CE3lejmztcAROMUEpmTq98vP0k9p/vC5Aitp+VLDAxCHcWv63I OdImPhMBNNuwl0LC/XMLxhFHhwL/ug6QU5wEIXgtzxejw86w== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 40x3et2q2d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 12 Aug 2024 04:35:25 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA02.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 47C4ZO3J007648 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 12 Aug 2024 04:35:24 GMT Received: from hu-apinski-lv.qualcomm.com (10.49.16.6) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Sun, 11 Aug 2024 21:35:24 -0700 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH v2] ASAN: call initialize_sanitizer_builtins for hwasan [PR115205] Date: Sun, 11 Aug 2024 21:35:11 -0700 Message-ID: <20240812043511.3148242-1-quic_apinski@quicinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: qNNU79Snnonyu-Kor5cN2Y6yHH0OY8tW X-Proofpoint-ORIG-GUID: qNNU79Snnonyu-Kor5cN2Y6yHH0OY8tW 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-08-11_25,2024-08-07_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 suspectscore=0 impostorscore=0 phishscore=0 clxscore=1015 mlxlogscore=848 lowpriorityscore=0 priorityscore=1501 spamscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2408120033 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: 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 Sometimes initialize_sanitizer_builtins is not called before emitting the asan builtins with hwasan. In the case of the bug report, there was a path with the fortran front-end where it was not called. So let's call it in asan_instrument before calling transform_statements and from hwasan_finish_file. Built and tested for aarch64-linux-gnu with no regressions. Changes since v1: * v2: Add call of asan_instrument to hwasan_finish_file also. gcc/ChangeLog: PR sanitizer/115205 * asan.cc (asan_instrument): Call initialize_sanitizer_builtins for hwasan. (hwasan_finish_file): Likewise. Signed-off-by: Andrew Pinski --- gcc/asan.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/asan.cc b/gcc/asan.cc index 9e0f51b1477..5f262d54a3a 100644 --- a/gcc/asan.cc +++ b/gcc/asan.cc @@ -4276,6 +4276,7 @@ asan_instrument (void) { if (hwasan_sanitize_p ()) { + initialize_sanitizer_builtins (); transform_statements (); return 0; } @@ -4694,6 +4695,8 @@ hwasan_finish_file (void) if (flag_sanitize & SANITIZE_KERNEL_HWADDRESS) return; + initialize_sanitizer_builtins (); + /* Avoid instrumenting code in the hwasan constructors/destructors. */ flag_sanitize &= ~SANITIZE_HWADDRESS; int priority = MAX_RESERVED_INIT_PRIORITY - 1;