From patchwork Wed Jun 19 15:43:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13704223 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 9C579C27C53 for ; Wed, 19 Jun 2024 16:15:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D9276B0384; Wed, 19 Jun 2024 12:15:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 287D86B0385; Wed, 19 Jun 2024 12:15:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1016C6B0386; Wed, 19 Jun 2024 12:15:43 -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 E6CE06B0384 for ; Wed, 19 Jun 2024 12:15:42 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 8BED9A077A for ; Wed, 19 Jun 2024 16:15:42 +0000 (UTC) X-FDA: 82248138924.11.35075D7 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf28.hostedemail.com (Postfix) with ESMTP id 12148C0015 for ; Wed, 19 Jun 2024 16:15:38 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=GBGOGqpy; spf=pass (imf28.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=1718813733; 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=kU/N+IjLjtGivjpGyVY04YO0GR9T1vNZaCjuWWP4qac=; b=OSg+wfRxzDflJ4qYxKOhE5UkdPfYYEBYuBWWYNR436tI+K87+Pz0nnvaROPNPArdTU8KUI bYLkMxOg5jFKH/R+eFFiA5k9epWIsTdXkfriimbLChHcuT4J1at85dPnnHu/xxxOYjj6Mi qqBiX/1XYJ1nb0vURzTHuWOH/2ZVh94= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=GBGOGqpy; spf=pass (imf28.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=1718813733; a=rsa-sha256; cv=none; b=aV+D4Ess/bNOATGNSGb4XLlw6Nqa5T8KvxuN3RjgD5s3gcbpbD0XDrNAeLqlIiHVseNRlB C5FcT3IMaMt0gIJUX69FAKHnbgN9kg1NdpLst4b6/cq+7aOCbK411mSh5FDdONBBEzW7Gk V0D+YTgKf3I7cBoE0HHMQoeLxmJuXD8= 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 45JFR25k017473; Wed, 19 Jun 2024 15:45:42 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 :content-transfer-encoding:mime-version; s=pp1; bh=kU/N+IjLjtGiv jpGyVY04YO0GR9T1vNZaCjuWWP4qac=; b=GBGOGqpynXJjYxo0tKIHVnXjyMfLe dHN+TxmZtPfm8MFrSGhVpDcFYCd8skiJtWfz9ewAIz3KAHlqyit1kCsO8as1R80h 8yh0GQV1D3sDRt1ziJIupCw2slxM60G7JUuZyOsoFvwI9L/75L8uWW4y8xFt29qJ BvPSS6AAF9LTC35o+pbHD/ewocN/rqIr23QnBoyR29HnD6ux+kyRHo0m2M+Izq5I JODaJm6LqWHWsZO+aVeXwlriGn+b2S+F+YHB2SX/H3SOuh19nEAV3HgGCS35tWfe F5z4XSN58mCiWsVWxxM5H1rH7DxYJ57XzzGIDOajHNw+/vRWLjeKAZJwA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yv0p9gau4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Jun 2024 15:45:42 +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 45JFjfHl015754; Wed, 19 Jun 2024 15:45:41 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 3yv0p9gaty-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Jun 2024 15:45: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 45JFhxil023990; Wed, 19 Jun 2024 15:45:40 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ysp9qdype-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Jun 2024 15:45:40 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45JFjYUQ51904956 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Jun 2024 15:45:36 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3501220040; Wed, 19 Jun 2024 15:45:34 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D73242004E; Wed, 19 Jun 2024 15:45:33 +0000 (GMT) Received: from black.boeblingen.de.ibm.com (unknown [9.155.200.166]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 19 Jun 2024 15:45: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 v5 01/37] ftrace: Unpoison ftrace_regs in ftrace_ops_list_func() Date: Wed, 19 Jun 2024 17:43:36 +0200 Message-ID: <20240619154530.163232-2-iii@linux.ibm.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240619154530.163232-1-iii@linux.ibm.com> References: <20240619154530.163232-1-iii@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: DjNn8wQivNgXS7aGEy7fFO0UzqFKCQyA X-Proofpoint-GUID: dfntroPUBr8RU8mCueQtnLhKjRrBTJS3 X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 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-19_02,2024-06-19_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 clxscore=1015 mlxscore=0 spamscore=0 malwarescore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406190115 X-Stat-Signature: hwbr3n1119kbj3ydacrxa478tuax8gs4 X-Rspam-User: X-Rspamd-Queue-Id: 12148C0015 X-Rspamd-Server: rspam02 X-HE-Tag: 1718813738-327414 X-HE-Meta: U2FsdGVkX19e3X43V5qvQL6z5ML6uXslKBkZ3tuqOEDIBsM4AyYMochVTiTOip0YijgzeY8UlJcwZEu0gne9+w4gpNYzYF/co38yjBhqX8aiZJUwjAdNqrRecjPDvMTGdM57Yzf0H6L4tB5yggIFWjuQF3Y5V4jbpCu5YQ+knY4PpLJ0s8ZO8fbXeQ5S0088g00X8ktOhrCBgpUQwdzarnLQFbbgvXdj5KGtPLvdpCRrS/Op8kGLi8NbYn0h0TrkMglgo/PWTkVvBFLH/t+qM9jsDUqVNTJ+zsrv/pwFU62PRIAZIR2s3fRMBu7fc1pgaoMNAseIrIyT+4K4lPe7/iuxqvgrUbbJ6E+AVKnvvq4SnWQP/YDjkRh88OcA40KTDXPMbN+rwdRY9c1QQU9TiAbm4enA+k7rKP0mwCSM6OMfjLJTDwt8IN5vqFjizPzxTaGWir6GmjyFvtbLiViTnP0znFsHzIqatlUsaruwXJyuwsoYW97DsyooApIy1QoENh6oSOnyesuC+HXMcVwpM3LxDCaKRG6IBKwnJkqk5OUPniCP6+Cb6PV+fWgZJ7B2tlhta9d8pxJph9Ija5+5J4TIEMh89XC/dWI5YLP6SsRobnRLHdtXpobCr4EL+4yS3GQuIhG7qf4qbVHMLqZ1HrfTwyVPIiJldkiOk8cRrXsB6iAgRdlvYSmxk76IvXQrbwn2MJbBrD47DeNZrHTNNRSIEEyR990qUKM4bThyVSIQavpq07ebsT4pfxyTryaG8GKbzL/wZyauoXZa7yE6cJ1Xf6qGbZ+T/FlMiqbcVtV/pDmObei8eRO4ovYa/9OYQfGiWXFsXA1hyffmAzeT3XdO4eDBjlyMrInfhdFMUyLSAFwNU1YEQzRv1HXFtJ59Jcm2nYA5iqL7R5EZvULf4VQcNArFdH7mqtxHI+Mfvppu+nTf/0XSrnKTLYZRbIgNWJPUT0XxKE1g8Tb+ZVt SFbDpHz1 //TfFUnpxCo+imq8+hze3VfasXK+COtLaRrY/1QD2bbcTqtvv7ySfgo+eozN5H6wxiNTFfpxrVXiNXe+WABI7spkgYetrryg6gT4H2G7rlN4C7+xBJ+z7+H5lVGk7zKzS6lvX76exsxVaITQiwL+tEGQpxQWQs3JGK9iLDpFmfQaVey+1FmtRjHFYqLXvT17ftO4qoQpC1BfKspc0WLhLLkycdkvGj73UCpgwdSTlNxIvwQs+w0tUY/GTL2p606FFGC1CRldDcP+05zr4VKKKBwY2yO+gD9ZybV17LHDrnsx85jSgypCk4BdZ6afeP3t8bJ1pRF0a9ukV+OAyMg29djmNehqtwDpR7aSTt7BCtn96uqnz9FPfHfaEdsLetto5nK94934aIQ0YysS3t5uNyZhx/g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Architectures use assembly code to initialize ftrace_regs and call ftrace_ops_list_func(). Therefore, from the KMSAN's point of view, ftrace_regs is poisoned on ftrace_ops_list_func entry(). This causes KMSAN warnings when running the ftrace testsuite. Fix by trusting the architecture-specific assembly code and always unpoisoning ftrace_regs in ftrace_ops_list_func. The issue was not encountered on x86_64 so far only by accident: assembly-allocated ftrace_regs was overlapping a stale partially unpoisoned stack frame. Poisoning stack frames before returns [1] makes the issue appear on x86_64 as well. [1] https://github.com/iii-i/llvm-project/commits/msan-poison-allocas-before-returning-2024-06-12/ Reviewed-by: Alexander Potapenko Acked-by: Steven Rostedt (Google) Signed-off-by: Ilya Leoshkevich --- kernel/trace/ftrace.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 65208d3b5ed9..c35ad4362d71 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -7407,6 +7407,7 @@ __ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip, void arch_ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip, struct ftrace_ops *op, struct ftrace_regs *fregs) { + kmsan_unpoison_memory(fregs, sizeof(*fregs)); __ftrace_ops_list_func(ip, parent_ip, NULL, fregs); } #else