From patchwork Wed Nov 15 20:30:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13457281 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 42597C072A2 for ; Wed, 15 Nov 2023 20:34:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9822D8002A; Wed, 15 Nov 2023 15:34:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 90BD480022; Wed, 15 Nov 2023 15:34:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7852C8002A; Wed, 15 Nov 2023 15:34:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6139480022 for ; Wed, 15 Nov 2023 15:34:26 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 24D9814095B for ; Wed, 15 Nov 2023 20:34:26 +0000 (UTC) X-FDA: 81461341332.09.F630AE7 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf02.hostedemail.com (Postfix) with ESMTP id D6BE68000B for ; Wed, 15 Nov 2023 20:34:23 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=lVtuxA53; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf02.hostedemail.com: domain of iii@linux.ibm.com designates 148.163.156.1 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=1700080464; 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:references:dkim-signature; bh=ZvlPFgCBT1EmH5DZbvTajf8H3CytU5Hp1eV8d/t1KuQ=; b=DQU2l6XgC+h0GLNyODdIxOheyVzBVDsojn+Ws+yCpvme9tP2z0d+8Tgpty60eBjmZXTN0E BA5GJ3wj9DyKG3EeH6K20deE6OP1abEzgPg24dZGDmCEvNr1w+gL7WKu2e+YLn0IcBY2SV rNOPwzHJ7rfg5HquGhYFD09zdsfuaeQ= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=lVtuxA53; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf02.hostedemail.com: domain of iii@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=iii@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700080464; a=rsa-sha256; cv=none; b=pf6VTDrvA5sLaVa/o246WmE729pAVXrhfa8K/6YFqejwLMEmQv+WZCMvIqCMtSvaPywZjC Cs1r7vhrj1koZ+8SBypU/5q61uOKZYg+cfxUZVQJXCYCidtJ4YgU8PqXnTAMLowPucPUUg Wd9+qJRPjXvuMfHwFo8fpqW3mmW55Jg= Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AFKWucR031174; Wed, 15 Nov 2023 20:34:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : mime-version; s=pp1; bh=ZvlPFgCBT1EmH5DZbvTajf8H3CytU5Hp1eV8d/t1KuQ=; b=lVtuxA53NpIasyLyVxsb8g2sO7n8jgKLZr6WnZGjEh2kEwrnxiopq3HP8FWgG/eQr9Xr VtL3WdYhimBH1fouhUkdcRUzN33PjcEORadF8YUTrABEMSxyViiwsRsDkAJsXvhhQ+XP AAuztH9oUnPhD+B38hj/6Jwi2GfSUNsu/rs8rorkASI1NPrszjVN0Zy76poT0sD3oAsA tfDurEFrPEVlDMukq5rTIihutLZBqdHJtzkTqdMmkA8orFXaIIF9SGWftXNY62W18CRw gRht2dTN9GPQ0WvFXWJMk+ei5CPWLLNTytlpBbnw+YdeEFYe5iyGfV7sxGEeULGOvfbJ ew== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ud543g10h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 20:34:12 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AFKYBS4003580; Wed, 15 Nov 2023 20:34:11 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ud543g0yw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 20:34:11 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AFKIvA1015481; Wed, 15 Nov 2023 20:34:10 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uamxnj0hb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 20:34:10 +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 3AFKY7n744434146 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Nov 2023 20:34:07 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DE54B20043; Wed, 15 Nov 2023 20:34:06 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 835E020040; Wed, 15 Nov 2023 20:34:05 +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:05 +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 00/32] kmsan: Enable on s390 Date: Wed, 15 Nov 2023 21:30:32 +0100 Message-ID: <20231115203401.2495875-1-iii@linux.ibm.com> X-Mailer: git-send-email 2.41.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: s_HIgjGFEkw2r82SbnJKsme_JpUxwIpl X-Proofpoint-GUID: O24-gF0cUI_VPwI0_OAIJDvWxXDnx7n2 X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 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 phishscore=0 spamscore=0 adultscore=0 priorityscore=1501 suspectscore=0 clxscore=1011 mlxlogscore=999 bulkscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311150163 X-Rspamd-Queue-Id: D6BE68000B X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: yicq66eoaez8m9f3zz8highwaq5m5m1u X-HE-Tag: 1700080463-380916 X-HE-Meta: U2FsdGVkX18mt11cl+OGBbwj5kDPMHQXzC1PQKSSEu2SDWwD5hr03I7Cy4OqUp2aOINQxcFAiLEdXt30AQ2OIGzQFQS+8xdNs9ihFOCmVwXjvkzku108W4G4FUym2uvPjQevH5OVEAKpt1ZfiQFR2NzUNOFuDszwJ9E9kPnKVso7vtssKqpHvF+QRZXxCAAoJHy3fTRKKP/5CxyYleOF+tOsQMivzfVehf3NMIVw8GsZ5t0H9CJjOCCxeh/Sdc21JY44FOWp1ceI8rvmTmbQ4YXBtrY/IKmgcA9fH0Mnoha59f2TflT4GRfmYCheDvygtf1IQR1KMPkKiWOWpiFvKZD8MH3+/TbsB1lpxOs2Ia139WU54cN/fqpt8UAlfDHETeCYZ56EPP2adbkUVK7dzHh17SyV7DtFCanprc808uTwZ7kt1z/UMowHMkN9A+V2B3ZFtdbHJ5ezC9nYWqGXoZlL4DJ+TJoue7lpUWQ/bCot3pUVShm9OkTMAjoE+v/NtyV1MLtKxoosWMWymu8ltj35RyrcckjrUYzLoRIPOGczpHXJsaQvmqSGAe9kXlqlTHKL2vMRl7r+5O/oPKrLO+VEmGEsT3nLCOZAh3Q+I45e5LSHjCnYc4Wg+WVevVBdY9ttFL0wd4w/NQP4Qt8750B3APTheFJSTq+Knu2S94tRqbky39sZEGoVtt5PpAmhwSZcYFElYz7+NN9Tnxa9LEiyL7URr5Yi05oLVh9hjwVfDW7e+amayBs5mrSc6hA/D9Scs1/kgfKIJJ5y/hk0/1akTIn/ljrEQqKxUVh8Bc7NLy0vw7QbN6flZymZVfUVDc2kLPK3E/xty8fWuVdpREngDZ6BIvMeJ6XuI5RyM23scdn4BJAoBRqk02hL2bnHoadNgnwMqy43LeJFA1v+Zt+tDJ8xegki0L1EETBSbWan+cMD9b55f/pjlBZS0U8Pbm66Wm6V4vqxXKUf8A9 JP6oMZ+w vluG8RZsdp9C5sGGKykeHy+7V8LuYrupgBCMJowtqmYSml/W900SO1TewXHmFtaRH7Webj1YSgMvcIYG8G/fxu+Rgaq+r7fMpbkamO8H1+cDfGDmR4+8udFPFopjZbNE300jCKzyLEcYsmUbq5r/+20Hn0p2I/x1mBRWdxFB6elEbfPfh4jvv7NaZs5VXC1FtIzWLRRrA3colWYQ3/wPSzFJ3LBr995kfgewWkjjKLkpzfJ4ol1Vig3gCq3pOtcSHpaOO X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi, This series provides the minimal support for Kernel Memory Sanitizer on s390. Kernel Memory Sanitizer is clang-only instrumentation for finding accesses to uninitialized memory. The clang support for s390 has already been merged [1]. With this series, I can successfully boot s390 defconfig and debug_defconfig with kmsan.panic=1. The tool found one real s390-specific bug (fixed in master). Best regards, Ilya [1] https://reviews.llvm.org/D148596 Ilya Leoshkevich (32): ftrace: Unpoison ftrace_regs in ftrace_ops_list_func() kmsan: Make the tests compatible with kmsan.panic=1 kmsan: Disable KMSAN when DEFERRED_STRUCT_PAGE_INIT is enabled kmsan: Increase the maximum store size to 4096 kmsan: Fix is_bad_asm_addr() on arches with overlapping address spaces kmsan: Fix kmsan_copy_to_user() on arches with overlapping address spaces kmsan: Remove a useless assignment from kmsan_vmap_pages_range_noflush() kmsan: Remove an x86-specific #include from kmsan.h kmsan: Introduce kmsan_memmove_metadata() kmsan: Expose kmsan_get_metadata() kmsan: Export panic_on_kmsan kmsan: Allow disabling KMSAN checks for the current task kmsan: Support SLAB_POISON kmsan: Use ALIGN_DOWN() in kmsan_get_metadata() mm: slub: Let KMSAN access metadata mm: kfence: Disable KMSAN when checking the canary lib/string: Add KMSAN support to strlcpy() and strlcat() lib/zlib: Unpoison DFLTCC output buffers kmsan: Accept ranges starting with 0 on s390 s390: Turn off KMSAN for boot, vdso and purgatory s390: Use a larger stack for KMSAN s390/boot: Add the KMSAN runtime stub s390/checksum: Add a KMSAN check s390/cpacf: Unpoison the results of cpacf_trng() s390/ftrace: Unpoison ftrace_regs in kprobe_ftrace_handler() s390/mm: Define KMSAN metadata for vmalloc and modules s390/string: Add KMSAN support s390/traps: Unpoison the kernel_stack_overflow()'s pt_regs s390/uaccess: Add KMSAN support to put_user() and get_user() s390/unwind: Disable KMSAN checks s390: Implement the architecture-specific kmsan functions kmsan: Enable on s390 Documentation/dev-tools/kmsan.rst | 4 +- arch/s390/Kconfig | 1 + arch/s390/Makefile | 2 +- arch/s390/boot/Makefile | 2 + arch/s390/boot/kmsan.c | 6 ++ arch/s390/boot/startup.c | 8 ++ arch/s390/boot/string.c | 15 ++++ arch/s390/include/asm/checksum.h | 2 + arch/s390/include/asm/cpacf.h | 2 + arch/s390/include/asm/kmsan.h | 36 +++++++++ arch/s390/include/asm/pgtable.h | 10 +++ arch/s390/include/asm/string.h | 49 ++++++++----- arch/s390/include/asm/thread_info.h | 2 +- arch/s390/include/asm/uaccess.h | 110 ++++++++++++++++++++-------- arch/s390/kernel/ftrace.c | 1 + arch/s390/kernel/traps.c | 2 + arch/s390/kernel/unwind_bc.c | 2 + arch/s390/kernel/vdso32/Makefile | 1 + arch/s390/kernel/vdso64/Makefile | 1 + arch/s390/purgatory/Makefile | 1 + include/linux/kmsan-checks.h | 26 +++++++ include/linux/kmsan.h | 14 ++++ include/linux/kmsan_types.h | 2 +- kernel/trace/ftrace.c | 1 + lib/string.c | 6 ++ lib/zlib_dfltcc/dfltcc.h | 1 + lib/zlib_dfltcc/dfltcc_util.h | 23 ++++++ mm/Kconfig | 1 + mm/kfence/core.c | 5 +- mm/kmsan/core.c | 2 +- mm/kmsan/hooks.c | 30 +++++++- mm/kmsan/init.c | 4 +- mm/kmsan/instrumentation.c | 11 +-- mm/kmsan/kmsan.h | 3 +- mm/kmsan/kmsan_test.c | 5 ++ mm/kmsan/report.c | 7 +- mm/kmsan/shadow.c | 9 +-- mm/slub.c | 5 +- 38 files changed, 331 insertions(+), 81 deletions(-) create mode 100644 arch/s390/boot/kmsan.c create mode 100644 arch/s390/include/asm/kmsan.h Reviewed-by: Alexander Potapenko Reviewed-by: Alexander Potapenko Reviewed-by: Alexander Potapenko