From patchwork Fri Jun 21 11:35:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13707334 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 ABF62C2BA1A for ; Fri, 21 Jun 2024 11:37:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80DDD8D015A; Fri, 21 Jun 2024 07:37:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7673A8D00DB; Fri, 21 Jun 2024 07:37:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 573168D015A; Fri, 21 Jun 2024 07:37:37 -0400 (EDT) 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 2FC528D00DB for ; Fri, 21 Jun 2024 07:37:37 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E119BA0DD8 for ; Fri, 21 Jun 2024 11:37:36 +0000 (UTC) X-FDA: 82254695712.19.FACABED Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf03.hostedemail.com (Postfix) with ESMTP id 95F9520015 for ; Fri, 21 Jun 2024 11:37:34 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="gCmb/jd+"; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf03.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=1718969843; 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=vRIGGJ0mlpmXtykTCfy1hgLPDIwkKj27flwRq3yJTor4kgmAnHYzT+DlG3awMcHMlNtXxy CBdJ6uMb8Rp8zazgraSqiMoaDarJPS7jUmHfYCGvsT70E9Wyplh6Pfv96Y2vO8o+eVJwzi uHwVKo63fDpDO708ggbZxfBalSpnki4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718969843; a=rsa-sha256; cv=none; b=UEzJtuAPaQLIJnty/4P65NLHUdajOjB1TMpqM1nK71nnLmQZUL3va/6HDkJqlqhyOjr+vD AWgaHw8gp5kP426/Gru0IHnTiDWwTa3cyaKR8RsLs+Vd7gS9PDoUm0y5w4q0CQWi+bKWSS dj/1q2+EWMW2iaoqU8FJvIF8SMg16cg= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="gCmb/jd+"; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf03.hostedemail.com: domain of iii@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=iii@linux.ibm.com Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45LBZFfl019981; Fri, 21 Jun 2024 11:37:27 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=gCmb/jd+tRaCgIblXL46fw3Ru9gvd 3CF3TjMMxMyVSfK1w6i3qjTcd6lVoOatzRayVDautrWNG5BYAR0oAEvUDpOyl6eM 1qytDXjek7pQv3nyZ2WYxSjrUmEndYwez31/qIt9IM0I/9yz73snsc1r37y++asY iTD8m3+dOt9kqx2xXJuIZ0IBZVnZRUbnkvwsS5/NE3Rp8KD4ozFspC0RczzV7XYl a/fUrV/AVQ5q9WbZjsGVRgMQprjN/eQd4TuKJ+/OhPpAy6oCpGFjybRPQgKjTRNg lCUWyKQl8DchFTWzVky4/8c0IMPHnEvynd0st6Y+3D2gN4iD5rkoS7Ilg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yw49cgpwb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 11:37:27 +0000 (GMT) Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45LBbQpQ022007; Fri, 21 Jun 2024 11:37:26 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 3yw49cgpw6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 11:37:26 +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 45L9H76V031933; Fri, 21 Jun 2024 11:37:25 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yvrsppv5n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 11:37:25 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45LBbKJI51839450 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2024 11:37:22 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2B0822004D; Fri, 21 Jun 2024 11:37:20 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9548A20063; Fri, 21 Jun 2024 11:37:19 +0000 (GMT) Received: from black.boeblingen.de.ibm.com (unknown [9.155.200.166]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 21 Jun 2024 11:37:19 +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 v7 18/38] mm: slub: Disable KMSAN when checking the padding bytes Date: Fri, 21 Jun 2024 13:35:02 +0200 Message-ID: <20240621113706.315500-19-iii@linux.ibm.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621113706.315500-1-iii@linux.ibm.com> References: <20240621113706.315500-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: vituer1Uvt-m-Bx1xIgcKWanRH3GTkhf X-Proofpoint-ORIG-GUID: v4Bwds8AEd2AHVddJ8G2HfSGwp0WqKu- 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-21_04,2024-06-21_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 priorityscore=1501 suspectscore=0 clxscore=1015 phishscore=0 impostorscore=0 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406210084 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 95F9520015 X-Stat-Signature: gunab9hbts7fz1eur8myz5b6yx7jgxcg X-Rspam-User: X-HE-Tag: 1718969854-136421 X-HE-Meta: U2FsdGVkX1+OIMUaqfBRT9B+7ujhvVF/u7TOXjFKD2CXXPxSZ9lk5sxYeRIfVyakoIEqwBfyLoOvM9OKf6ByaHFgppv9uikkzTqmxngfA7K1lqlRB3Y/Lf3Hx5jvNOS1899jzVwwNo1HrIOPAwJ/6UhSRJbe36UJy8zqWKl0/Mf25OsPmWP4iU1keM3QcFmVpdH6HO8eTFgUAJqw4gUrSOi4GWjdU5XmxCzISM2Ewuk2umNTvz1bmSgBQzTyfUx3QLIpWXe9aJem0q5P3lUvIUg6xsmnpfYXNLzZyGuwhSaG2gp1LDV0LNb4+acy+x2IjkBIQFv7pz19dMZBA88CRza7vWTsWLLLVitz9HzxGAHsJ6u2JSqPO6uAckwTlHdrlU6XN4lb3rA3OMVBCU/sKYHJPP4LwYe9y0Se4luZAD5FyOSgFoA7b0F5kKLf+WK9Qdr7aKtMNWUhUkqBOD2rkWwF22VFDQLIsnmcrSFu3fNjr89fMe9nGlb5D2qwpNw9AXwa2s0ZaxFmGlP6I06Xo9rNjaiqn+pIGR6hdvsOyL2Mdcmm5jBbcD2brPx0E02HkDtZWbsUqoncTVxvbZLLfg8I7oum6GVQP0OkWZTFzcJQlxniRqMAZvqUSUsEuv3h7ATqPwZRszkTWP3o36zisZR8VYBn6vvRxpfEglnOuDY2NdQn2FD6rTMBJOeIvt0NnTA71WFhggnHCE67FEv4ZCoM8vS5zUdjF/Q9LDAdywtRwJ9vNl4VhIzco1bRp76bPEd5r8W+7e5f0KQmngq3u8Rws/Hdnxbh3WqdAaOh20u23fixNIe2DdEOoaVJIoqr80Rc8AlVHRTF8KqhjXN3Gn+pQDNNuP/yGdHzIbti3Uf2T6PzX/zqk2kglN5Q+UwZc8Bf7DiCQRb/vztyIj6zlBjZgzzjq+YvsZoHU7t1Rgs9zK7IvOstIr77QQu8Q62QGflEbwYdcrIHv54LXXK eAzgAlxI kkrtPErvjmYTpt2UssuNFefAwldSx5rEJD/WOXCLdHU4mYJx8IZjdlombxdleTwGDTl6kiXSYQPZiOfeFTB7DFTh/esVecRcNt2rpHZazSxiqTzODe+K1ikRLEYdJseV70UcIIPSa9n+XPHhfo7HTAZfT+dpBON4l0tXb6srwmrdBUXLLRcSJJ0zb8eYRhv28mlczkzoahsjwqfRw94DA0Ueg/FysuAAd7lvAMC4ztVAk3YMxegu9W/BDUVNwN+hVw04tiFG+5J0FSMj8TAA1PzLvDiznIfbYIdxAIqpLYpRvvs17YjDFAHRhc+cpeIqCNcAfQYHc0U4vSKanpt2n0UaiDvQym+zNYxsl1YoG0W+klnWy+7rS7rBfBw== 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 Acked-by: Vlastimil Babka --- 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;