Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp699180rdf; Tue, 21 Nov 2023 14:04:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IGio+WMZ2qt3FKb8sFAPS+MfceBaK5xU6NYEIeo6cI8xqSHKDupD9sXdTx5jiTn+lmOfq/R X-Received: by 2002:a9d:4817:0:b0:6bc:f276:717f with SMTP id c23-20020a9d4817000000b006bcf276717fmr709970otf.13.1700604295721; Tue, 21 Nov 2023 14:04:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700604295; cv=none; d=google.com; s=arc-20160816; b=tgNJiKySVKyTOZXUPziWAyNSlkogHmQZXGc54oXABm2/v1cnk7au72Mnx5X7n7+fii KTiCdgruTuNNykY2CifpMxRMD+QNHCgIr/3o6TSObHtaFNfuhpvS31v1DyqK2KA6id4/ cVZZBG7sPf90OOsBYsrVcAsU0cmYyw9Sh+vWSHi0Pd5Fcfu7C7QKKoZwD7UyP/e41F+E sq7pRXc3LnotBLgnoI3lyxAFL+qim7o2ctfoUSnTyXmrzrFkfVI4sRKcAwZrbJVnHYMc 8eMSaDy1+/lNpEDDAfV3OiNwDqEFXeHH7zhAlJisZC8KWOoMsOHbBg7WmANqU227zWni 7qaA== 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=Jw5Y1HvNWq7xyQLWYP0uulKSfMNkdY0+zz8uCuv3y/0=; fh=TQATEbdDZNcnk8L2eDP6eFL9HlexFaHIexhR1TH2IlY=; b=nPSEDPPgae/loOIaGs1EH3vN6v3kTZa+MG75DN5Mc3rlryIe/MMdlb5hy8hBhCUlTl ESeu6ekWomeqrUZ1FxboE3r5ghATDjRnB7ihr7Qk8hU15Pq3P4W7NPmy96TmiA3o2UrP 2LUAfyxdIm21pb0R2oACSQqOd8WigIfC7CY7U+vfTyxxVAi2Mkvst6MDxrjv2gG9UTgZ /HC87yXuJaFtqwZDZwwbr+2PGV1AbIrOKxCixWwU6fHqebavfS7n1y+sLaQdHdiiMApO ZrbJ++/f8djj8UsoGbGgy2H7y25Qx67YNEBs7wH2ts9UruiCivDhgqiM0zy/ndMJaNgG jhcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=IzMejt7N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id f27-20020a63101b000000b00578da80ac3dsi11177914pgl.80.2023.11.21.14.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 14:04:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=IzMejt7N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 5E9398020BF2; Tue, 21 Nov 2023 14:04:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234900AbjKUWEQ (ORCPT + 99 others); Tue, 21 Nov 2023 17:04:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234476AbjKUWD4 (ORCPT ); Tue, 21 Nov 2023 17:03:56 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1860510D5; Tue, 21 Nov 2023 14:03:08 -0800 (PST) Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3ALLfDl0025205; Tue, 21 Nov 2023 22:02: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=Jw5Y1HvNWq7xyQLWYP0uulKSfMNkdY0+zz8uCuv3y/0=; b=IzMejt7NQo7glexgqNP3In+hN9eFEdhQDC/eGPrtUex06xGfRkDlauZFtqd5m2QQZPuh eFZhBvRvDVSkk73E3hcYQC9EKOoJnWEPjpMZdtna+ZzYTTsXNstltldsWBmIiSeOE14E ieokMr72lmrvqZXAbRfuPZtt29pxv2HDBNJhXmIbhf9Mn8neK8zaV3j3AD6w8JZafrgs bFa20kGrTTbej1O3T+vrRbK2h4X4KJrY7wQOBK6JfizyMm4nJRl8M/m6/Tsaxf+tJdYv ObxqVvg7BMcbMc16/XzL9447YjM+IoN98VP6T7Cc3MArW+JXB18Ub2LyCxn52NKdRKlZ 7A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uh46a1ac9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 22:02:51 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3ALLfLdc025865; Tue, 21 Nov 2023 22:02: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 3uh46a1abu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 22:02: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 3ALLna3m011089; Tue, 21 Nov 2023 22:02:49 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3uf9tkbbku-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Nov 2023 22:02:49 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3ALM2kHB9831118 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Nov 2023 22:02:46 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BF49A20065; Tue, 21 Nov 2023 22:02:46 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 526B620063; Tue, 21 Nov 2023 22:02:45 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.179.23.98]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 21 Nov 2023 22:02:45 +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 v2 23/33] s390/boot: Add the KMSAN runtime stub Date: Tue, 21 Nov 2023 23:01:17 +0100 Message-ID: <20231121220155.1217090-24-iii@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231121220155.1217090-1-iii@linux.ibm.com> References: <20231121220155.1217090-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: qe4SXelpch00WHhO8n0hLeZh5nQleolM X-Proofpoint-GUID: 2hpmIJbsI3XPvZcXaNBq09lhpHW9HWVv 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-21_12,2023-11-21_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 phishscore=0 priorityscore=1501 bulkscore=0 adultscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311210172 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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 21 Nov 2023 14:04:43 -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. 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.41.0