From patchwork Wed Nov 15 20:30:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13457297 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 5E731C2BB3F for ; Wed, 15 Nov 2023 20:35:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A265C8003B; Wed, 15 Nov 2023 15:34:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A83B80038; Wed, 15 Nov 2023 15:34:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D7098003B; Wed, 15 Nov 2023 15:34:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6278180038 for ; Wed, 15 Nov 2023 15:34:59 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 43193160AAC for ; Wed, 15 Nov 2023 20:34:59 +0000 (UTC) X-FDA: 81461342718.07.267FADE Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf27.hostedemail.com (Postfix) with ESMTP id 0271640016 for ; Wed, 15 Nov 2023 20:34:56 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=EXuxBFfm; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf27.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=1700080497; 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=NhhCYesztOa7Jqvt4x0Jdgg/9LLiWk0vF6FRHTpFEGQ=; b=GQtn81JPbLGsxB+guyQI5mNKMDjLZqQA1pdSOLM0uPN5OsQxoFh1UBvUA7mkDXgP2Y8hyw PQRqshuaY1OFUKx5oo4sKCG98QdxxHBmKewA249J26JgWm/zPiZahVdptycflVCQvitNcW DCn0/vgMG4IbLGTYTjdk7vU0kFVP5RU= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=EXuxBFfm; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf27.hostedemail.com: domain of iii@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=iii@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700080497; a=rsa-sha256; cv=none; b=VERG0eu1VATLfJMTt3E8MfDEI/hdygytaami98uVSJ7RTjpWF2tmVnQhirytqtyBCoyuj/ 1UgZ2NQuyOSRz64k/2obaoJ8ABEp1UVKS5j1Bnsqm7VLy2k3wJW7GmVZVSZzXKK4B6qZ88 CSVXK8S1GUJHlUXGSpjwfd7acTMW3Cg= 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 3AFKKGMt020174; Wed, 15 Nov 2023 20:34:51 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=NhhCYesztOa7Jqvt4x0Jdgg/9LLiWk0vF6FRHTpFEGQ=; b=EXuxBFfmlBxmPjShKXyWRnqdsbxq97IsJbT/Ks6kWrcaswZ6w0ZpMUCZ+yg7uoG3ILdk Mt0m0AtMCHIDaAgPHVErnbPvnAwe6KKpRm50cCb4EG9liRFF1h+N1xP4T+nQFifkXvi0 qe1glwAzZKXeHJOqs5iItl8C+vCOEQHKN2o3miCs/gaxQjkxDYNkFoCKsCP5AQUKhIYX aoM0vLhzuZPCYdFf6Xg2vrpO6pLSfLTRDycsiHi+EUnAR5gqjmIQJ4iJm7wOheGMogGu q93nD8AHnhTCLdZlJ5e5ezvm8s65u3LZuX+6bwqr7Zo0ZPa2KL+rWuajwsRQj0HTngmU 0Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ud4xc8cef-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 20:34:50 +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 3AFKLkkX024302; Wed, 15 Nov 2023 20:34:50 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 3ud4xc8ce2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 20:34:50 +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 3AFKItQt021588; Wed, 15 Nov 2023 20:34:49 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3uap5k9kcq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 20:34:49 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AFKYkcm23265800 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Nov 2023 20:34:46 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4F4CC20043; Wed, 15 Nov 2023 20:34:46 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 01BB120040; Wed, 15 Nov 2023 20:34:45 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.179.9.51]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Nov 2023 20:34:44 +0000 (GMT) From: Ilya Leoshkevich To: Alexander Gordeev , Alexander Potapenko , Andrew Morton , Christoph Lameter , David Rientjes , 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 22/32] s390/boot: Add the KMSAN runtime stub Date: Wed, 15 Nov 2023 21:30:54 +0100 Message-ID: <20231115203401.2495875-23-iii@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231115203401.2495875-1-iii@linux.ibm.com> References: <20231115203401.2495875-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: fkncNkpgvEQiGUZcGTO_3XR7T-3cRmrK X-Proofpoint-GUID: 4uSiq2gXcSEbCiwoTCWkXAyd40BPgJJa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-15_20,2023-11-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 phishscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 suspectscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311150163 X-Rspam-User: X-Stat-Signature: 7rc6rn1u5hyb5patkmnn1bsrqp9ecqia X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 0271640016 X-HE-Tag: 1700080496-843160 X-HE-Meta: U2FsdGVkX19pSb8l2R2nrIt+LqwtjRCNkyStF/m39q8A6gawJL3qFQvM5144L97DmqraAl6KemmbUw7xOAEjGrggWEKhi+BRJx4RqqPELFj5cJoDlGzthEJUTj4BSU/SS0aw+QfnDIIiDgh4RKqMdsiPpR1qAMGuHf/0235Vnf15yZNJ2Z7D8q4cDiDSFwbo5aYoLWmaiBK5CLG571nphRO9naaOI6Xq3iHVlOZ9FwIXgfxJRgSb1AbFeskwAXm9e5L4bpAYSjoDePPK3hPKpRa7+nChONkHfR1FN6yDSDcBc2IcVsAJIqBXHjXSopXVXdHv6gYbX06Dk7Abgh3Jbrx1zSlR6/W61coFxzhGSqc0030aCVxbiv3ZyhXWurMq83UD+oPJFw1i7qE+c8iGqhYJeztqKekU6Kma8wtqFthLey9zjoaoHTs8/f8eVWd50rqAGMwjQJhFC61eOEyJcW4vKY6E09EDxFmtmRh3giTiDs4xPEcnGobU8kCU6+Pug2KChd2V11WYrUwCU29NP55TpaR9uH2iVfXFNQ/92Vfrb0yBlQMI0NmsYp7bhqe49KBd7sxS0/eTT86/t8/P2p74ZWxbHOvjFZwWCR04Zxpl0afes+F7Wm2yWmsF5lOfkUBz6s3/QMmYR1fbE4dMQl9dTNDQfmmQ49t5+JaNLrmG/uje5XzRrq30rHbXV7DXk+O/UJ5asTfKGhjpxUfGWMv8DFhB0isdxzL+OjMkbC0uUoJtrFEaVQxozFm2HXCP1Qyu0aPfPT12mxLEGxmX4BIgUOaE6BXdVdQeev4gm6wk7yFr9Yi1AybUiFqBtaek/PREnrRuQ+9478SBKJOzdJP6ZHzMtl3PsmHkI1CxYuvS2VVvP+F1w/ywh4b0N0nhiN4/JqhsGuxQ/f3wMCopUymUzZerG9s3vyoh9Ve8fXtSR2W2DLErsZmM/J6Jmm62i6tMtRMwf9FxsbdyoA3 efg//gYz FuUYbKziJz2lnUnxG5wAKa9HHLiREmZw25U3dqk0b/we5JAbZN1xLpfGiaO6xCvMK5nOqMR2HasXn+m3RRyMrroJJdMahW0EPz2c0/l79rwxgU4CgTERJYH/7sWVFey84xImpbGLDPDs3gfxGJpDcsnXoK71KfqnwcxauF0DhzhxK8guxbpJ7BrciHg1/rGa5Gvw1qpfoUkLa+xhQ34al4F8gzUxh2OCoFsD8qqxKCku8CIthUCo6PpxbBq3ElYtCercDJKWHBUP1uGxmJgIkAqARBuxQDfkarO2sinbWRSECxya5KTAJibe34w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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. 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 5a05c927f703..826005e2e3aa 100644 --- a/arch/s390/boot/Makefile +++ b/arch/s390/boot/Makefile @@ -43,6 +43,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) +{ +}