From patchwork Thu Jun 13 15:34:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13697008 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81F5AC27C4F for ; Thu, 13 Jun 2024 15:40:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD8D66B00B6; Thu, 13 Jun 2024 11:40:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B84EB6B00B7; Thu, 13 Jun 2024 11:40:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B0066B00B9; Thu, 13 Jun 2024 11:40:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7B2DE6B00B6 for ; Thu, 13 Jun 2024 11:40:02 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 30F64A0199 for ; Thu, 13 Jun 2024 15:40:02 +0000 (UTC) X-FDA: 82226276244.01.DB145C8 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf03.hostedemail.com (Postfix) with ESMTP id D152D20007 for ; Thu, 13 Jun 2024 15:39:59 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="p25W7o/C"; spf=pass (imf03.hostedemail.com: domain of iii@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=iii@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718293199; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=erZvlatfvJVe/hx7BkMgZ/7G1oP598/R1HnuL1JF6tI=; b=jKuBTSgP/EFkUkREZhqXaxhsDGJ12MHBUa4vkWfkw8GPEDycbEwk7HrJz6y4guFpasoux4 k37x2dj1X4TFkqyVerhyZtzCgunYVh64qa5MDxBAMSFP/gNbhiXZ5zF0qYFdIN2QBoOhdP 3BFV3InhkVs2XzYTmOkLVWQgXJv4uW0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718293199; a=rsa-sha256; cv=none; b=xm9zB4320QZUqNa6bm78ElRfYIVR6wTwEJo//wRlACi+ALbyLVQEqIhZvgkmUc08bkwJdp wOCmALjbUmGvjM2uHBbPGw5OoKlirh8Kf4YPVaXF1iaIv/N5qz3hMatyjLB1tiXMTMvDAU Zk4HNyrnDyaYGmlhT/Lj/GTfWViyOBM= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="p25W7o/C"; spf=pass (imf03.hostedemail.com: domain of iii@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=iii@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45DCR5FB031311; Thu, 13 Jun 2024 15:39:53 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=erZvlatfvJVe/ hx7BkMgZ/7G1oP598/R1HnuL1JF6tI=; b=p25W7o/CudREsmrJUDH5PLBqNrljD tqE16he8MhCwPgkg5ElsKa+qj98SqC03fly21qIg922NsKjc827uqcq0YUhmeYTv S4D5e/Be34FRsBN7fhFZ7h4nfl9f34pcu3TIYKi2Dx/fiaphS5JeIcqTI9E2/7t3 odXw2JaVSzdAR5Ugqn052FHFETAvsaWtADHDkqDbChrTdGyKFcebKkCEaBBOZyHf o5GKEcWB/lZBABQa61AK4/MNrw/yBv3Tj/sbhuu/CjE3Yr0OQUcv8gGWwIB6rtgz ciOq8/zMPfVc7jKuX+2Isy1M3h4w4/T3ssw0Ki+A+NhCLRa32bXjQXtAA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yqq4rt376-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jun 2024 15:39:52 +0000 (GMT) Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45DFddrG026714; Thu, 13 Jun 2024 15:39:51 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yqq4rt371-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jun 2024 15:39:51 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45DEfGBi028808; Thu, 13 Jun 2024 15:39:50 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yn1mus9fp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jun 2024 15:39:50 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45DFdjMV14287222 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 13 Jun 2024 15:39:47 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 09C862005A; Thu, 13 Jun 2024 15:39:45 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8BC4F2006E; Thu, 13 Jun 2024 15:39:44 +0000 (GMT) Received: from black.boeblingen.de.ibm.com (unknown [9.155.200.166]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 13 Jun 2024 15:39:44 +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 v4 22/35] s390/boot: Add the KMSAN runtime stub Date: Thu, 13 Jun 2024 17:34:24 +0200 Message-ID: <20240613153924.961511-23-iii@linux.ibm.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240613153924.961511-1-iii@linux.ibm.com> References: <20240613153924.961511-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: bDXYjt3QTW4jb1VpShiRGF98SrMCVjqT X-Proofpoint-GUID: gWs7Typp_vs9CO1C98hB18fAlqU4x_JW 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_08,2024-06-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 adultscore=0 spamscore=0 mlxscore=0 priorityscore=1501 bulkscore=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406130109 X-Rspamd-Queue-Id: D152D20007 X-Stat-Signature: abs3465zqhfazxysuepuw9efj3jwt6nk X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1718293199-322245 X-HE-Meta: U2FsdGVkX18RbAwCUctzPz4LXnCar68GRfA+p3hjtONzNrCeju4BWXbK5a+d98iRYdvV6VfAgTCbOkleFHcFOL3emU5gQvsA8U2Mt5EGOmZtEQ1J1god6iPTr7VcWID0CTriXxDniI+dyOfgmvdr3W6kSEo9Bk8gZwFfRFoKBR6TPAstf/kbbfHee6Su/ieHvYQQJSphLyzRR79utzAQyHOna0FAgccl3NnIfDi3D7HlZwJij6uWGbP5IsIqlHwzLHzw7rQ/AZI+17hEZWuVe5ClUDoAusjVsigP4ZK8dzLYoOttIqYDykKDI3MBsI9BcahpcqvDW6zk325n+P7JBeCV3ericH+wh1uRV0aT5ovhgcSqR3NuJsRfrrtoiccoIApLRnuwy6w9JuSlfjgh38YGkbyC94VVC7n5KfpFkGA6UNPdDNviTqQXzmf27LnBONJo3KEcch39oTRagFn+yrkovU7u1F5ShGtlw+HYh0MGV//YMM0W08J59kQDCRRNEUAqX7XGSIa1xi0l+iABq0xgH1RZUhqatg6CaRxVxVIZat58JBoa2xdKIbD2GsYSO+t5t5WljBpjS2WkSfChCDgd40LY1KOVJFStiwLNWoLn3aNRlxRKuJUMw+qGKkMP0P9ht2ylwiVflpVyznKeh8zdA2HMHvzdtt4zihTKTZwmhShsTmkTnSdf5qRSnIIltxtVe5bRbjKfj5fric6FYee1J9CgNCmGq4WEsXX8SPk1Rg2S4qdP0KlOC6Mg+3Oz81upowli3DymJrYDhu1jgZB4h+odkvJC/eULjFWPh9B5lXZFj7yKkmTl7+gx+t/n5/fjaDX1lrIssVvmyKDhuHXWbIft2cpIZyU7OnYEuffyLgSM0Qq1ZGlvbMzOhrOh7QTnEXlHuSNQLxF8AEt2H7QflGA86XCI0dQhOd9E9CIJWMLoSxn+KNSQkCzKp2etuB3VBEEeQZVCjtqVaok BSmu6RcQ mGMXI6kz/PQ2sW7z8hvrxV8s4hEoYXGgm5ftdah3/lCDvR4Px5DBRFKaR86u7caHzix8lSqFY7q2n03ZqLGJKlmKFRhzyi5Clm1cbXoVzMmouIolM8PI4yzvkTT4+RIbhqfhd3A72WCW3ppIKxEDcEcviqOKEWMuEJZ3wmnJ7UPbxqudkpFkayl1ZFOMvUF6hvGIixn+LlT2BMC0xLWBKLiZn2opMFAuGTDOg6Df2aQ9xOMCsrpaOuAHReFK7jve2AEnQViqJp0I6cdr6PjGVqI3NjWhSEE2a4+o0sqeskRBCc/ZCUAljeFiy9iWnRWHxWMKuas2aefKPOoKSnHMRYeazj6vhNTkgwB5Lq/EN9xUvm8g= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000130, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 526ed20b9d31..e7658997452b 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) +{ +}