From patchwork Fri Jun 21 00:24:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13706579 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 3DCA7C2BA18 for ; Fri, 21 Jun 2024 00:27:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EED958D0102; Thu, 20 Jun 2024 20:27:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E4BA78D00FF; Thu, 20 Jun 2024 20:27:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8BB48D0101; Thu, 20 Jun 2024 20:27:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 91C808D00FF for ; Thu, 20 Jun 2024 20:27:04 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 58A341C130E for ; Fri, 21 Jun 2024 00:27:04 +0000 (UTC) X-FDA: 82253005968.15.5C3B0D2 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf26.hostedemail.com (Postfix) with ESMTP id 234E5140006 for ; Fri, 21 Jun 2024 00:27:01 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=HsKrXHfy; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf26.hostedemail.com: domain of iii@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=iii@linux.ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718929611; 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=gKMpqyYVBDSZBskm92uf+QZfcxYfiqqBCpn4Rw63BWERBgPTt4nLnB9ABaFo0RJITxzGfz R1Ggc2I6eq6Tw8WKTvfl69ef/XMfJU+5vdOZavUp0zBrPWFC4bHoNdrcz/pxdbUSUwOJ8y XlGrEZMwH+WAFnjgIVLoV67f7iTfvc0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718929611; a=rsa-sha256; cv=none; b=dpzZxP3oG4J/mTQKQ8tuTnB4xylw2lSgwbd+1lYRl4ZL6FPPCflU34OX2ZH9cqsGzmzAKQ CkOe3SFP3AjvtFEemR8kxNxBhUTPPQGq3TjS8OPqyntIV2EfThBLJROuOhIvQ44J3LUWJc jHHQYaCmOKLSawBL1yI04/kJYkXzOkE= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=HsKrXHfy; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf26.hostedemail.com: domain of iii@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=iii@linux.ibm.com Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45KNugHH003832; Fri, 21 Jun 2024 00:26:56 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=HsKrXHfyZxSWrtuzJP7wLSRWK+8xX LiqnptjwY5fqq9Lmc431QzcNHWRMtVnrAYIKILELk4SzMWXqvXAXooVj6dLuSQC6 P74diip+lzqrViFGaFkG4JVMVsjUC4zfxks9CPeLpliSulX24vtrq4aPfODCU7dM NlHOgNDVuWmN43ZM7SO46HVNnLXu4wttutr4vvWAOm5N58L4cEWV08j/5xv6p8QV S0zfwT+zfDEk1YhrXxKE4r28hdBd3032ULCSiNpUk3FuBz2RMoTVk0Reb9DEeyyZ TeSQjkNH7FuUH96q2q947fMTZornH5LdzCWKSes7/2yUpVZTmWYHfQeeQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yvvrr07tv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 00:26:56 +0000 (GMT) Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45L0QtVJ017251; Fri, 21 Jun 2024 00:26:55 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 3yvvrr07tq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 00:26:55 +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 45L0Qo1h007675; Fri, 21 Jun 2024 00:26:54 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yvrspamqe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 00:26:54 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45L0QnIF26542838 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2024 00:26:51 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F0C52004E; Fri, 21 Jun 2024 00:26:49 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 38C3920043; Fri, 21 Jun 2024 00:26:48 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.171.10.44]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 21 Jun 2024 00:26:48 +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 v6 24/39] s390/boot: Add the KMSAN runtime stub Date: Fri, 21 Jun 2024 02:24:58 +0200 Message-ID: <20240621002616.40684-25-iii@linux.ibm.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621002616.40684-1-iii@linux.ibm.com> References: <20240621002616.40684-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 9dcK0ufp-zk6wCTiX_6yHz6QVSDZTOKz X-Proofpoint-ORIG-GUID: TZ4RD5EfkJbUFEJTfU6D8Katl0egKWBY 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-20_11,2024-06-20_04,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 impostorscore=0 adultscore=0 malwarescore=0 spamscore=0 mlxscore=0 suspectscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406210001 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 234E5140006 X-Stat-Signature: us8owgshfebai57o73gyi19puepy4i6n X-Rspam-User: X-HE-Tag: 1718929621-376586 X-HE-Meta: U2FsdGVkX1/GOPB5g/XVaF58JsL1Xt7fg6bHlEAp6cYhqIyJ0dVZvPSXdqKcT5UZ4yGBWTcsr0keDCjL1nc1GFdV5wiaFrGIfDPU2olaf7FrOFBnOJAokJ34Hy/XN46LTfjcCDtXkyZT/mhKimhhlqQl7i8s+N1lYiQViOn5CymCTkfMAHefuBDFbEfvkBJNEnYyTLvEPSGCCJ6C9E5ZTrUuiznUkOqi3fHVPTBHQOg/QDid9tZFYPphPHyJu5wK2Ak1rJhDLVqekior6RJq0YwLN6by04bUUZUr3Sl+/hhbjWlIjgAg01TnuFu1pOJRTEeF1YMExsB/5N9dADR/Y/mhAF79kZmuukZDdvEtdNSjonq5px21oUShqfbXIrT5eLMb6S51WkBqNBiHGzGmx4CXnKrRLYxPwwSYP8hpKIyZVp7ElyT4tzToyXPMRgaJbc8nGzUextFpYeg8SbGS4/ufKd9Z8d64TqMdOfv3CZMeuiL7PDCdXCiKwX7JPhTADMmWlJLyx4q3OVzmjVPKosjiqzhlf6jmeoJl1L8THdcds1Sld+udrJcoSMuTZdy7nVtL1olPYBKMRugwS9jSBbBt3u22Dv93Do8I8rw2bnJ718ov7vcHPsY3utE5R73R7t11/eU5dlXgnAgylF3WuNIVr+xrQJX8nx5hYO5f0UwF099qnOnm4bxhP0RMJ5rUcCBIwldbWjJXteEUOxNe5o9A5Xs6SzipM9bnZ6a/XcfpzEzfOkL1izSU9IUr5E7aCaQ77mLcbzy+Vd1EsrP3dGh58MfePwd3ASYRm7eG1LtRpPEpayPOR4msT0VH6aqqyckJtebFeNEHpMbkv3UN8EDZQff/5zyvCqQGCNtx58GMM1CUvxDAwOykrFh3LfeqE+3YTC8ZXKI4t0DrRgdxDSxC22Eqy9AXqpWRTYzNInR6J6rL1KOsn5zGzHjpdWAZP3tMyYE5ZUpjahdLTf5 HCs9IZOI H+PL9nLVVCMLkp17/cqY5/AHCsT418mP8l59zoB2eZi8C+5OeEKAU/S9AollZWI8mIyEO+FOTKmLrGpSoMLG2GSvNs1C3YlE/69Hi3TcJFCGo83CAI7WcyQKcIhJFRXYvBwcImytei7sOx+p0skfFlQPdkEn4qXt65/TOaoN1m0uguxPEZCJjIvr3SAweCaRzL5Bpfw3S26ZbyfQg0vivtY5ZCQWjo47/wiiou5yFjfaVXhC8KQetH099rB6t6R0Bwu1vKYjK3sECV3qXdp1TEqvm26ZMbVanSUcif8bybIEuDpdyzzj2ZRzsBKf1odBCjjnKWZJckpXOi06HZf5RbgSdBqt19r1iKN8LUy+scIcCJ4U= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000011, 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) +{ +}