Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5659278rdb; Wed, 13 Dec 2023 15:50:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6ZH08M4u/+RgdFo9hYwukYVhTpEGp81NiHxfBQc/lENnOShAvy+DELCJw5FA6vuj/y6qQ X-Received: by 2002:a17:90a:51e2:b0:288:7c05:b249 with SMTP id u89-20020a17090a51e200b002887c05b249mr6699519pjh.81.1702511450806; Wed, 13 Dec 2023 15:50:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702511450; cv=none; d=google.com; s=arc-20160816; b=dOGNGZN9FZfJKwgcINHp4l5MK2yUT7CrwnvIh0S99WXYtPbLZCq3ANQzykKgcVEnZu Hc9YrV6dduk2hkfEwddVPQH3tNeb5NABgTHNo4A7saRRnS3/+tUk+KvFZLgOsq6bVpAL mVlz4H4ydjzbddorOz6EcXJQdwFfCnBvVrWWm/J9rqhx4N2muaw5yzkn/N+/K6gPORl9 31Bow9dyKVx6M73OY4WpIs8KxoK1Fzo9UdUtIYj0JM1l6P1KXxm3Z283V8QFXqKSNZo2 cPqU5b7zkN3XA/A57ejL9SI9WpFtWbef1fdsinIZ7yZieLzslWSfkN3VJ0GTIa0dGYFR boXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=j2GQd3hufGtxn26BXfXN2VPH4hRg4OAPUwhi4unL9oU=; fh=TQATEbdDZNcnk8L2eDP6eFL9HlexFaHIexhR1TH2IlY=; b=zl6CKt+q9U3/DOF3Fa7C2K8VDhaSYns3V2t64U/ZTbjEnPt0lMLGtph0oyzeRE9SsY 6ZVezinscQ5Y3EAVKgGQFlgJ0E49hBv7UZAehEYItt9tsR967wS2y477MMC9hLG7RtcG Qd6AOA6hVSwqhkisEKmp2/RqT5d09Z6NzRAInzcQoZyNc3YEa1gYOd7XOZpHz2vSReB0 Cs+CISf7Wa7s5qDDP+1kRRsrrJ2/6dbj1YbiqF1UbMthggRz1ipG3dxrCZ4k8KWaEsqu ivfMbMqdXwaMNPivxUi7M+LAoA9MeZbDUdU4SsPpeimlaI6LJU4ggcME+aq2btkDk+uf vagQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=E2pyhrNm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id a3-20020a17090abe0300b00280ca5f4ca5si11561892pjs.113.2023.12.13.15.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 15:50:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=E2pyhrNm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 9433D8278BA5; Wed, 13 Dec 2023 15:50:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442685AbjLMXu0 (ORCPT + 99 others); Wed, 13 Dec 2023 18:50:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234276AbjLMXuH (ORCPT ); Wed, 13 Dec 2023 18:50:07 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4AD519AA; Wed, 13 Dec 2023 15:40:57 -0800 (PST) Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BDLrAsR019617; Wed, 13 Dec 2023 23:40:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=j2GQd3hufGtxn26BXfXN2VPH4hRg4OAPUwhi4unL9oU=; b=E2pyhrNmMiCiIfKvy5Wu9ZXem6XPay3FyNo5qwlGIT/0LHK9OCxWPuP7zXXyoM1uBxzb CExYESQ6SfdSd+Wz//xv29DKleH/XjFqe8uIkISc15UM91Zp9T9bApRfTmWgff9eSyAh xezoN96f6pel6IiNLbpEPXnz6RssdMdC99v4RlznhtskMs5aKl6SlvKBIfXj79JMTFFY gFncANGncIhR7TqGz0kZ1vFcQXvyyp7n8YlBrTukV1WL2undZL5v7bGG7np1ShTWox13 mDYp1PmuOvVLbT1d6aUcLvbcPcB5hpmfKPfzOqvmrteon9uCYu9EUOiw4eOt8mZ81zO1 dw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uymwuj5vm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 23:40:23 +0000 Received: from m0353722.ppops.net (m0353722.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3BDNeJQj027678; Wed, 13 Dec 2023 23:40:22 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uymwuj5dj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 23:40:22 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3BDMuGjx005066; Wed, 13 Dec 2023 23:36:45 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3uw4skm9x0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 23:36:45 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3BDNagMJ15794750 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Dec 2023 23:36:42 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 941F220040; Wed, 13 Dec 2023 23:36:42 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E23F20043; Wed, 13 Dec 2023 23:36:41 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.171.70.156]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 Dec 2023 23:36:41 +0000 (GMT) From: Ilya Leoshkevich To: Alexander Gordeev , Alexander Potapenko , Andrew Morton , Christoph Lameter , David Rientjes , Heiko Carstens , Joonsoo Kim , Marco Elver , Masami Hiramatsu , Pekka Enberg , Steven Rostedt , Vasily Gorbik , Vlastimil Babka Cc: Christian Borntraeger , Dmitry Vyukov , Hyeonggon Yoo <42.hyeyoo@gmail.com>, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-s390@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Mark Rutland , Roman Gushchin , Sven Schnelle , Ilya Leoshkevich Subject: [PATCH v3 21/34] s390/boot: Add the KMSAN runtime stub Date: Thu, 14 Dec 2023 00:24:41 +0100 Message-ID: <20231213233605.661251-22-iii@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231213233605.661251-1-iii@linux.ibm.com> References: <20231213233605.661251-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 4lAACWdvN8WbBuqQJ2B2W7oAjf4WZHdM X-Proofpoint-ORIG-GUID: -6xNZk1Ck_XK02XybYIjXFr2nKMVO1v3 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=2023-12-13_14,2023-12-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 adultscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312130167 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 13 Dec 2023 15:50:48 -0800 (PST) It should be possible to have inline functions in the s390 header files, which call kmsan_unpoison_memory(). The problem is that these header files might be included by the decompressor, which does not contain KMSAN runtime, causing linker errors. Not compiling these calls if __SANITIZE_MEMORY__ is not defined - either by changing kmsan-checks.h or at the call sites - may cause unintended side effects, since calling these functions from an uninstrumented code that is linked into the kernel is valid use case. One might want to explicitly distinguish between the kernel and the decompressor. Checking for a decompressor-specific #define is quite heavy-handed, and will have to be done at all call sites. A more generic approach is to provide a dummy kmsan_unpoison_memory() definition. This produces some runtime overhead, but only when building with CONFIG_KMSAN. The benefit is that it does not disturb the existing KMSAN build logic and call sites don't need to be changed. Reviewed-by: Alexander Potapenko Signed-off-by: Ilya Leoshkevich --- arch/s390/boot/Makefile | 1 + arch/s390/boot/kmsan.c | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 arch/s390/boot/kmsan.c diff --git a/arch/s390/boot/Makefile b/arch/s390/boot/Makefile index fb10fcd21221..096216a72e98 100644 --- a/arch/s390/boot/Makefile +++ b/arch/s390/boot/Makefile @@ -44,6 +44,7 @@ obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE)) += obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o obj-y += $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o +obj-$(CONFIG_KMSAN) += kmsan.o obj-all := $(obj-y) piggy.o syms.o targets := bzImage section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y) diff --git a/arch/s390/boot/kmsan.c b/arch/s390/boot/kmsan.c new file mode 100644 index 000000000000..e7b3ac48143e --- /dev/null +++ b/arch/s390/boot/kmsan.c @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 +#include + +void kmsan_unpoison_memory(const void *address, size_t size) +{ +} -- 2.43.0