From patchwork Fri Jun 21 00:24:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13706657 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 5A0ADC2BA18 for ; Fri, 21 Jun 2024 01:48:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E36CB8D0117; Thu, 20 Jun 2024 21:48:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DBF3C8D0111; Thu, 20 Jun 2024 21:48:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C38F08D0117; Thu, 20 Jun 2024 21:48:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A17AC8D0111 for ; Thu, 20 Jun 2024 21:48:19 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 214D41C1545 for ; Fri, 21 Jun 2024 01:48:19 +0000 (UTC) X-FDA: 82253210718.25.7F77E00 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf16.hostedemail.com (Postfix) with ESMTP id D244718000C for ; Fri, 21 Jun 2024 01:48:16 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=tcPUg5+W; spf=pass (imf16.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=1718934492; 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=DjuPcXR1BibZz5Ch991GiPtCxAY119xb/qfTqg6kigE=; b=cVLs63LdPCMDWpVs9KbG2HG5gJCPzi29ReqqQLQZ7FgATMdmwu0II0gmDvfj3VG4kfBda+ JSlEpi0fRyru5o5bKK4UHB4JRbzt4HQSczeNxBs6z1B3PnwW+VUbqJM3zkLAv6eaNAHxXq f+o0YcmgFS21WYyKbYXRE+5ErELmVos= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=tcPUg5+W; spf=pass (imf16.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718934492; a=rsa-sha256; cv=none; b=oWIkdPgMKk1xbIG0xPLAN3vswANMC2bwzzmMeX/6cmSTDVjgymaWubJMs/ZauA0+tszfaF B3EdG+cTlXdpR9PEzSqFWvavFb8SfnV+yF72nxklalO4hQY5CG0GtcZSDymxSW+5496LTN mLSXuQ75cLeRfxvsUCtfXR2ICGzmuL0= Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45L0QnuZ007904; Fri, 21 Jun 2024 00:26:49 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=DjuPcXR1BibZz 5Ch991GiPtCxAY119xb/qfTqg6kigE=; b=tcPUg5+W+hgpGH+krm31HOBPTrWO9 +DwN/OijUc4YdG2S9x4PQuP91KRNyj0u6dHD6OGZqYSFY7CXNhMh4b2UmKG/ExnI 4LlB6a38g3SSDC3UyX5+LPThGXjReiAt8V/Jha0DgTll3n5JRlwWreEo8vAjWsux 1qhZPBSZo0CUVOdmR/tudy14cnxn7Fqdrj2ry/X561UbJ3RmikfQ5Vuq/z8KugvA DTFsAvh5a5zOK7s0dbwIiQZQK+y7T9TZUBhDhwvIRGMOy08fX+cAFY6Rv8cQwkkE ygUbC1JuBVE84SxG5n4UikZq9py7H0fDu/EO5mgnYRNlVvOgPZMTtKUQw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yvw8c875u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 00:26:49 +0000 (GMT) Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45L0QmWJ007892; Fri, 21 Jun 2024 00:26:48 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yvw8c875q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 00:26:48 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45L0PD2h031890; Fri, 21 Jun 2024 00:26:47 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yvrspjmyn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 00:26:47 +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 45L0QgCm18481484 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2024 00:26:44 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 052CB20040; Fri, 21 Jun 2024 00:26:42 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D5F6420043; Fri, 21 Jun 2024 00:26:40 +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:40 +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 18/39] mm: slub: Disable KMSAN when checking the padding bytes Date: Fri, 21 Jun 2024 02:24:52 +0200 Message-ID: <20240621002616.40684-19-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: s7hafDy5aFTcRtvqVQpLOtSJKs9sYlpb X-Proofpoint-ORIG-GUID: 2sowwXNvMO2B8DX6tP-_7374bKZOifoo 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 adultscore=0 phishscore=0 mlxscore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406210001 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: D244718000C X-Stat-Signature: dbhmpjk5b8cpnc4xiude5tozpcusji3c X-HE-Tag: 1718934496-114444 X-HE-Meta: U2FsdGVkX18XSCeso9YiiSQ7II7bd5AYnMXIRXpFIPzAhiCJyG8WBhVzoOsB3oNgWvAHfTJhIE+KRSLaQbbIND4ahrRuVNn1edNa/wpeghq2TjFg2MusQCcnxZ7n+jaYP4neRhRrT/Xttv2niRMt88XQVhE/nXpaCAyujTd/3pUiq4+4n35L1FxFfe0S5d9Y9Xyb1ZpFeBBIQB7meOjXLwVQU7rBFxXtLxJFmH+xE3g8TZixKW8meaIWEB6KPimd7rhytpplihzRYI38hdZiBlTlS339tWplZ+hYuXWiIETcWwQE8kkrMiSMBPWdyfwZGU4u4x6R0+8qhc8gOWySxK/dUqt0060FCTZI+37Pt9edED4/BVTUR6iYgOxQKCbDpDS5FlHtZYJecE9G7ucEMfPAZK1ZM8ByANyCCVrHXckG1OlD8wcJ5rVWRE/uuHdnDEoO+8QVl7/ClzJqqzIOEkRVIEYIX8dkPkkRerCxmrBg6jyIoEYCBAY1TAL2uBQEQcCNEnQKDjCwgNX2DE0i0+zTtIrRqCMIR8GYvjJnsEWksOUeNewSoNO9Uk7gkRh5Cpsws7WClSjRZhAgi0i+nM8yn3nDg8FQfY1Uw4yejb6oEnZFnASfnFKI439lctc4WkdrjppqI5/yCDkR5UAGR97WAW2KjVAs1/7vFtOhzgP0d5a81SWUBuEUYOAZ2X10vicSo9e7P08dlTie1/zGVYjwif6oxQ6O1qY9v8tV4M/JX1PGfqz9bXyyEMembvCFURNJemPDZhlJKG/RDqU+SzQh73BJ2WNGKY3zdxivMUfXCe89lPPB8sFKVMcygpCa7s1Uchylak6YfntnLVwxVrOiNNZWBU46KYPabWabESx8Ia2CPdUtz0lVf/H9ymTFo8Hu+gMuvMswC7LpeHEddHussqO4XYQyCUWe0e0dj61ayiUzy+KN+7afOyzsID0A/K5rXdIyYrYybaWhCGP cKZ8G7CW VewebgURk35gw4+1t3BYteJKyq6gQIiFTxDGFl5FtFVjpPZCTBEfGdrgvXUEHRNLACs0H84KsipMmtQvG2wYk+ljpck4B7o0irupsPWynUb8/8kexiyI+m/8eWt8DFVKJHhqgCI1LrmO9fIWO0vbvSqCtVcpV2Cv3JDVMjt9mU3CVYTrU7Pz5c8khmpADXHbiFaBS6t2s8eU2TZpmmKDDADbdAGmfH3q+QqBJOJCAiSLWtUZff3U/Iq/68IG/9NFwS4N2RbM7ht5otpBMIQ5gtOG7JkYbRHCE3YyOV0mh/68X3vo5jGs1OXGvPyiz5O3aNMeOwvelLW/hTL/bT6Wu2GR1fCrlDAiB+esvWTLtCVcyduE= 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: Even though the KMSAN warnings generated by memchr_inv() are suppressed by metadata_access_enable(), its return value may still be poisoned. The reason is that the last iteration of memchr_inv() returns `*start != value ? start : NULL`, where *start is poisoned. Because of this, somewhat counterintuitively, the shadow value computed by visitSelectInst() is equal to `(uintptr_t)start`. One possibility to fix this, since the intention behind guarding memchr_inv() behind metadata_access_enable() is to touch poisoned metadata without triggering KMSAN, is to unpoison its return value. However, this approach is too fragile. So simply disable the KMSAN checks in the respective functions. Reviewed-by: Alexander Potapenko Signed-off-by: Ilya Leoshkevich --- mm/slub.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index b050e528112c..fcd68fcea4ab 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1176,9 +1176,16 @@ static void restore_bytes(struct kmem_cache *s, char *message, u8 data, memset(from, data, to - from); } -static int check_bytes_and_report(struct kmem_cache *s, struct slab *slab, - u8 *object, char *what, - u8 *start, unsigned int value, unsigned int bytes) +#ifdef CONFIG_KMSAN +#define pad_check_attributes noinline __no_kmsan_checks +#else +#define pad_check_attributes +#endif + +static pad_check_attributes int +check_bytes_and_report(struct kmem_cache *s, struct slab *slab, + u8 *object, char *what, + u8 *start, unsigned int value, unsigned int bytes) { u8 *fault; u8 *end; @@ -1270,7 +1277,8 @@ static int check_pad_bytes(struct kmem_cache *s, struct slab *slab, u8 *p) } /* Check the pad bytes at the end of a slab page */ -static void slab_pad_check(struct kmem_cache *s, struct slab *slab) +static pad_check_attributes void +slab_pad_check(struct kmem_cache *s, struct slab *slab) { u8 *start; u8 *fault;