From patchwork Wed Nov 15 20:30:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13457289 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 56EACC5AE5B for ; Wed, 15 Nov 2023 20:34:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D398380033; Wed, 15 Nov 2023 15:34:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CBDFC80022; Wed, 15 Nov 2023 15:34:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0AE780033; Wed, 15 Nov 2023 15:34:44 -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 96DA880032 for ; Wed, 15 Nov 2023 15:34:44 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 6971EA0926 for ; Wed, 15 Nov 2023 20:34:44 +0000 (UTC) X-FDA: 81461342088.11.791A5E3 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf15.hostedemail.com (Postfix) with ESMTP id 05B09A0023 for ; Wed, 15 Nov 2023 20:34:41 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=LLyi7dxG; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf15.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=1700080482; 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=Prpv+ioyJJfZrf8ByIxPulecOh5L6EAjxoH7NJDKd6Y=; b=qqV/x3XdkhAOReymGjHdE0TvJJToqtKMRPJuaTpKpwtN5ueNBNL0BV+5ipvLrACybO7Jix whQzm99oDNttTHAfWfa1OPt0i4KorVRlm9m1MzlNIh5qKTe41QxmpBe5024lIa+TpJrvWo 0esQb1bgxub2jOel+jau8r1MN6x/Xkc= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=LLyi7dxG; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf15.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=1700080482; a=rsa-sha256; cv=none; b=1E5EDpVRPzal3n9xoPdYtieLsxQBcDOvdGIBMH5OK3+NfN5vnZf+BK1jWbGjRFVnAPecEN 9sIuSifN5U3oLme71Es2S/ELPs7+iFfMIsS7yodmmLmsyJnFJ0RMdv8mWyf8cq4abhgWCl Eg2GJGhkZ4mNLuHi4bGDkdoDPM14eMM= Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AFKFagp016166; Wed, 15 Nov 2023 20:34:36 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=Prpv+ioyJJfZrf8ByIxPulecOh5L6EAjxoH7NJDKd6Y=; b=LLyi7dxGghDJtCwcbzTDfPAfYRWuFYqoCzNZq+CXY521UhpAdBanrtkVWi2nQKT3NzOr HTgWqLLgi+FrE/mzwQtD84pNiS9Ls6XmkBvgUSKYBxP08wRIn8RynvX0JfUnN9pW6hwQ TWjJY4x5XO8czW1HFGUNhvxyAEx7NhDKHjuyZtbE4aCPyujBrr2c8PvHLXDFdOs7OQQ/ fIxjw3EpgGf9EZtYIYz+dHPurx9tvRFSzyGIcnhKsYmmz5cOfEfPB6DDGKm1APPJ+T7R rEMITFZFc7NUwSsXCKWV2CMz9cyk0g0h3cYReM28iNkodv0ZQYsqm28QpGNOQkk6Dvf+ zQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ud4v2rb6h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 20:34:35 +0000 Received: from m0353722.ppops.net (m0353722.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AFKXhxg002277; Wed, 15 Nov 2023 20:34:35 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ud4v2rb65-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 20:34:35 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AFKJ36O017548; Wed, 15 Nov 2023 20:34:34 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uamayj7a2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 20:34:34 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AFKYU8m22807222 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Nov 2023 20:34:30 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C4F4F20043; Wed, 15 Nov 2023 20:34:30 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7867A20040; Wed, 15 Nov 2023 20:34:29 +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:29 +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 13/32] kmsan: Support SLAB_POISON Date: Wed, 15 Nov 2023 21:30:45 +0100 Message-ID: <20231115203401.2495875-14-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: VtMKqHRGouLJud_Z04fE9mTeehVK5PxD X-Proofpoint-GUID: 9JnYJ8nyLC98Hq0I8m7EcHlY1F4CxSFW 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 mlxscore=0 clxscore=1015 adultscore=0 spamscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311150163 X-Rspamd-Queue-Id: 05B09A0023 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 8qbo6k4ug3ozwqxfz7ti5txufrphrwks X-HE-Tag: 1700080481-632307 X-HE-Meta: U2FsdGVkX18Eh8VHdgQ563ucAL1cLh2WUj5/Op6rqDDja5534E4qn750ceqnQPM9ZdxFE3zRvwopfy00gBlWUnRbLV8OVLPsJ4xJhq1E5suAVuVlRMKQRVnoQZaOA3CEH6FfwkzkAUwH4MnZm5kcfXcmZE2qeK6veTQ4zuln7EenP1gi3XsNLMJ5S2wdL25hyfJqVY/bED1u9/lOhM4XI9C4PTXPX7coJYAjJDdKIYrq+tj2Qds2VaBmQ1WHlXoM0DVH0JFM5+taLEpqY5yy3Ta6WdW5oKpk7fws3VruIoCNUJPujcYc5viERWzdy7A5jqlFq/E0syNEy/4DvDMIf178/QhcWJOuBNWsJWOxrM3MWCf/Z0jUzJyGwbT+SXBSrDKNQM/ZKzftkWVH1XNZW7W4iVR0zPTyv/johyLpLng7AOqKqeoTXl74BnmqOu/QE+qTgf/1ptwfkjWfngoAF7f1W0rHHby6zcAjTQgKD9yUmrT7kKF/F3dN0BceIbxY1NmtcC+RHxjuUK9QbUiWFAmM/woE8rBh4aX3mchVMkugN38XlegDWT/AyATxrnmW98gnn06jvIU36PVZ09jloBAo1EUNubaDOP5ttz3xkdh8acnPse+zLnQfz+39bJzC3DH7/FfBUvMkfzefMB5G0ako2DCNgA74V/uOb/8peo7O2WUTgTdzLpjdmetySuhKcUEbjP91gPW7LGqhyfbb9KoQ69xsXAy3MxvumZO+Imeh767QmtLDP4DM2IpIAH27y6yQhwIKfguwIa4SytE0Mm0zXxUvE3KB5wP/RAzR0a5uMpXys8YcmZH1HHTDKsRTX9G3TDw8Qf9S27M2uDgINgYAPNXjwkAiwnNAwBtKXKfVFJA/A00J9clcsZATeU0xTwLUIwIcKkfFvEp467jI1i4N9h2JYZQ3k8u0PaSYXLhegYBfpIXz7WPGdyriMuziI/Gw8gQrNvlX/ewmHW1 3u+MRrEl ceUD56alG4ysMbIGp0XsjqfEJU0efFpflEQF5GoIHMfXWxJ0RxFm0ePvT25qCOb9g84KxaVupY83YY+43gs9nlBnwMQtG2ST8B021IUodoXs4hibdFGXg6/DDPqeTUL9lmU3y8psCDbYC+OvvUCZyBm0P5cs4EQRMYGB5gJ1NPSZo1meCK8bOReM61PHGyfgkxpT1PIhueRv6XclUF5LsAGwUtJCdItYARptrq1Om3+HZBNlBylpTuk5q7LnZ6KcCScvN 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: Avoid false KMSAN negatives with SLUB_DEBUG by allowing kmsan_slab_free() to poison the freed memory, and by preventing init_object() from unpoisoning new allocations. Signed-off-by: Ilya Leoshkevich --- mm/kmsan/hooks.c | 2 +- mm/slub.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/kmsan/hooks.c b/mm/kmsan/hooks.c index 7b5814412e9f..7a30274b893c 100644 --- a/mm/kmsan/hooks.c +++ b/mm/kmsan/hooks.c @@ -76,7 +76,7 @@ void kmsan_slab_free(struct kmem_cache *s, void *object) return; /* RCU slabs could be legally used after free within the RCU period */ - if (unlikely(s->flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON))) + if (unlikely(s->flags & SLAB_TYPESAFE_BY_RCU)) return; /* * If there's a constructor, freed memory must remain in the same state diff --git a/mm/slub.c b/mm/slub.c index 63d281dfacdb..8d9aa4d7cb7e 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1024,7 +1024,8 @@ static __printf(3, 4) void slab_err(struct kmem_cache *s, struct slab *slab, add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE); } -static void init_object(struct kmem_cache *s, void *object, u8 val) +__no_sanitize_memory static void +init_object(struct kmem_cache *s, void *object, u8 val) { u8 *p = kasan_reset_tag(object); unsigned int poison_size = s->object_size;