From patchwork Fri Jun 21 00:24:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13706571 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 698CBC2BBCA for ; Fri, 21 Jun 2024 00:27:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35A936B0130; Thu, 20 Jun 2024 20:26:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2BA576B0162; Thu, 20 Jun 2024 20:26:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F34416B0130; Thu, 20 Jun 2024 20:26:52 -0400 (EDT) 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 BD5976B0130 for ; Thu, 20 Jun 2024 20:26:52 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 6F75B14067A for ; Fri, 21 Jun 2024 00:26:52 +0000 (UTC) X-FDA: 82253005464.18.3891B39 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf13.hostedemail.com (Postfix) with ESMTP id 3049320005 for ; Fri, 21 Jun 2024 00:26:49 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=TyYZLocx; spf=pass (imf13.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=1718929605; 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=wYZcdN8GaCldurJMmgBO/xn6iWaosLK3Wj+Mr2vvPT0=; b=XyydPndPAsYl2AGywd/dO6zBR+tY8R2nUOPfQTGWsiL5rblTc0V/H/DRp1x+LuPLE0Ml0h c2Rel4WwExoaIqKNZhfoc2ja/LA+XrJX8/XH5SgHVGI0/YGQQTDeebSs2n4JKSfE4niDGK lrJprfVKCWaiyd75t0LRuqttMSVZBBk= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=TyYZLocx; spf=pass (imf13.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=1718929605; a=rsa-sha256; cv=none; b=pHHZLHUZeD26VZgToGgNxjBw10P2EfAmsv60TkhU0hNogs/Xd24DNcUI0Nnem/pZ2pE36b Ev5A/cthEAjDD/tH3R+NJ2JqvUm6ZK7iXKsEx5OTi1am8JnyCuEkaBOB68Jd1TjOLGOVRQ RmiMNfqqlOPnF9p0LQll5d5X9+8axv8= Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45KNSIao032554; Fri, 21 Jun 2024 00:26:43 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=wYZcdN8GaCldu rJMmgBO/xn6iWaosLK3Wj+Mr2vvPT0=; b=TyYZLocxPDZI6g1LUnLnTM6RDN3bb M7v8iYyXepna0Yr+j7Hk5FEq7FoB2fFjURkk5+DxhadWyAdzDpOU7JjHFnnP1Id7 +q2ZzwdPHAfACj6Fq251rnzGpfoq06AKR8ergc/fm7tKTPfAHc+3ANsjdPV/3Spm UXnRKjK8/PCs8Kf1NymeznspqQ/ZkrqSzmGlc0pSWIrtqfPET2uyqxvvaxZP/2sf CHNIpssaZWn6vu4fcVb00iEWBPhdzTMdhj0h6pzjDHlVaBy2dxQWT3mbbf+jxvfo 585oNd2nePmOktSPHHnN6QYWTHN5g/dPs/pDZJuPCSSlyxVnghKF1WtWA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yvw8c070g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 00:26:42 +0000 (GMT) Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45L0QSYH022603; Fri, 21 Jun 2024 00:26:42 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 3yvw8c070a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 00:26:41 +0000 (GMT) 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 45L0EnR4019910; Fri, 21 Jun 2024 00:26:40 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yvrqujnwx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 00:26:40 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45L0QY4p49611188 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2024 00:26:36 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A9F7720040; Fri, 21 Jun 2024 00:26:34 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 86EEE2004E; Fri, 21 Jun 2024 00:26:33 +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:33 +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 12/39] kmsan: Introduce memset_no_sanitize_memory() Date: Fri, 21 Jun 2024 02:24:46 +0200 Message-ID: <20240621002616.40684-13-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-ORIG-GUID: HVD5r9y6qc451bgRBsPVDEcQFobrK51H X-Proofpoint-GUID: juOALtlB8s58b-RD-irHl1aByTJkzhA_ 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 lowpriorityscore=0 phishscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 spamscore=0 impostorscore=0 clxscore=1015 adultscore=0 malwarescore=0 mlxlogscore=867 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406210001 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 3049320005 X-Stat-Signature: 1zxg8z491qxtp5tmmsoiy6f9asmj9rez X-HE-Tag: 1718929609-242668 X-HE-Meta: U2FsdGVkX18hosvzVreCvUrIAHWV0bWhFtau2dsoMqB1YrvD3fFrF+uVJWMJzTVjLiYe5n3dxzEEa7BQLfj7uRJf/uOSRSc9GBZd7D4hM7mhJJzvd4jWAJLfN7do9rgE6d6JAjxlfURD3qy4pVawdgaa7lpWMMnJUUHyROVtfhdLuLz1WPw8x7aPlRUyRwMA4lZx31zlLE3WxCERBZTrwNNmkE2215VUiUYomgEyeV721URJW3UdyvFMJREk3cLokF8NW02Km2RNGIjyHy4jp+CmgdYQC2rkizTv6OEFOoKcqeYNjz12GDcZq8T2bsBwCBsMHlnaSmCIbzRYrINwaWFzQEpvS1T1Sw3mOGMuymCk3IxfrLZz1WYPxSW3F4AjDV201w7CLr9+dvv2Z961StPbxnvOrz1uxE/DlqnHuAyXXH9JNKHAZpptU8Sf+NWY08wckiHVOnj+ypFhbg82k0j7oqBc87fPe4dRKdYfGfJQRnSGzwJi+Ea8fnGzaAmf6eiXSLqUmSGJxxS1n5rxJhnNgUOcp9Njxdvn92JP/PutKGsIQ2ulgjgSKgVyS21H0KFZWj5m12DRsESe0PR9OkPuBWm3IEGytyhudBkSPGd9wYjpLQmKFUdwfBx+bua3j36ddL/6ICFsnu3QxJSbVc82nF16+fjFn5J733Vg9qXxRTD6mE637N/hcNLN1AxhVOYncyLWeFEqFUX3hH+YXvmzIMu8VoVctBIEb4eHj6YpL0JQhfEunjUNEBuXr+PsFNG0M7nS42ImS0T4BOVH38yxU+fAYxPPrW8dzwmgmG4yGqvcmPh4rINepuNk6pNoGjF5C/XxCeY6zXQvqGv16cgy8qFzyzdtXIpf6ApwjIqumX/rInfd8qOJtBOub/ooZbm9gYlNc/QrRYUJGcGypGu1XylpxktvsXctFLsGXoCGLPys6nC6ivnEewhFLGWiNmMzFZUceCB+qDsgZ27 kVS7J4az QNeCGKNh5ni2inhIfgEWvVGvmxGn/3TPEjUxsb47dFebklzOlviVQptgSQvhHE+gxX10vaZc2VnDQCY/JA2UJ8TnDl5bD93xKHcYgJtgdQLtwFKaNTvalSvT5m1pIHlZdHiK5WYn0OGLK3+MBABksUu3r3wHtgnKUJyRA7MKurV2gQSQ76O39IbX+SV558s/Fnbtx1ckmPaIAjfjBvfZkg7yDv4PaXUeu6tgUt8IuuUSNxF2tn3mkDALgWyQRODkIFf8nlxUl+6R3nRHaweatjeT/6qsnWkNVMjamoT1z4d0vEY+f14ghEAw4RBjw6A0ATuFf X-Bogosity: Ham, tests=bogofilter, spamicity=0.000066, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add a wrapper for memset() that prevents unpoisoning. This is useful for filling memory allocator redzones. Reviewed-by: Alexander Potapenko Signed-off-by: Ilya Leoshkevich --- include/linux/kmsan.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/kmsan.h b/include/linux/kmsan.h index 14b5ea6d3a43..7109644f4c19 100644 --- a/include/linux/kmsan.h +++ b/include/linux/kmsan.h @@ -255,6 +255,19 @@ void kmsan_enable_current(void); */ void kmsan_disable_current(void); +/** + * memset_no_sanitize_memory(): Fill memory without KMSAN instrumentation. + * @s: address of kernel memory to fill. + * @c: constant byte to fill the memory with. + * @n: number of bytes to fill. + * + * This is like memset(), but without KMSAN instrumentation. + */ +static inline void *memset_no_sanitize_memory(void *s, int c, size_t n) +{ + return __memset(s, c, n); +} + #else static inline void kmsan_init_shadow(void) @@ -362,6 +375,11 @@ static inline void kmsan_disable_current(void) { } +static inline void *memset_no_sanitize_memory(void *s, int c, size_t n) +{ + return memset(s, c, n); +} + #endif #endif /* _LINUX_KMSAN_H */