From patchwork Fri Jun 21 00:24:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13706581 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 DD787C2BA18 for ; Fri, 21 Jun 2024 00:27:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A9558D0103; Thu, 20 Jun 2024 20:27:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA4588D00FF; Thu, 20 Jun 2024 20:27:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CE4C8D0101; Thu, 20 Jun 2024 20:27:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 111578D0103 for ; Thu, 20 Jun 2024 20:27:05 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B84F7806A5 for ; Fri, 21 Jun 2024 00:27:04 +0000 (UTC) X-FDA: 82253005968.22.868EBB2 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf27.hostedemail.com (Postfix) with ESMTP id 6071940010 for ; Fri, 21 Jun 2024 00:27:02 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=AuMzDTLy; spf=pass (imf27.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=1718929612; 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=HEyEw+rp9bLKsksdLGa2wc6lPZGDdMEIf9huF2nZovEyC/dOyneMkHs8sRbr+zxGjDmU8E udo7vUzl/HZtfy6UdjtpSRExOQy3PVr3nI7tTgxrVjeCSbto6bEeWzq5NrgZqQiMAM6SvC XuKUnAwkWscoUucsafxIyYzi1wuhXTA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718929612; a=rsa-sha256; cv=none; b=rDPbjIxdQIwIjo3R1xzEFmUawRgBLWJ+uwIF7kNer3ZkIEK+dFiNF1MfbP5pzb8az/rC29 EAtCbpFNqNnAehROzqrFFEpRiupDe2zOY6KZnzcyJDbkBSh5FNkEjdWbW/RNW4N4t4PQRs WhRlFZdiT88zV1FQrEsKGYtc6M4zKo0= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=AuMzDTLy; spf=pass (imf27.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 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 45L0NBTm016908; Fri, 21 Jun 2024 00:26:29 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=AuMzDTLy/3A54qE2ADeLL2UYGU1wn a/QyESmytE/Idk4C+RRX2F1+bmBL2J51XQ2w3VbegEHI9Xh/+x7fIsJ/QRy3Obfa RyGhkd9itweYWHQBmX57vF0ALlMePUZzW5c1pCjI6XbfuUEqvyxop0OKvYRABLQM +TtFiipnaOLECsmo1LoJyPZNULrHRpNfwmL99Y0f3ukt8g+exLwPtYiYptUeo3X+ mPe8tIewf9AHZ7rVjRQ9ZCf9xgQNCH/uDNrW+QixZCKh0KLSJjEmIMAY7uNMkDws aVTc/6SRl+RhV8UsmXaFMR5lCaQ6stj9RlQf09zzUQtL/QHLWrX673rlA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yvw8c06yh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 00:26:29 +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 45L0QSYE022603; Fri, 21 Jun 2024 00:26:28 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 3yvw8c06yd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 00:26:28 +0000 (GMT) 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 45L0QFe0031032; Fri, 21 Jun 2024 00:26:27 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yvrsstn0g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 00:26:26 +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 45L0QLRu22872500 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2024 00:26:23 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3689720043; Fri, 21 Jun 2024 00:26:21 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 148152004D; Fri, 21 Jun 2024 00:26:20 +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:20 +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 01/39] ftrace: Unpoison ftrace_regs in ftrace_ops_list_func() Date: Fri, 21 Jun 2024 02:24:35 +0200 Message-ID: <20240621002616.40684-2-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> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: McwRRv8ORq2jBJVljLDOsf_BLReXo35e X-Proofpoint-GUID: w7z3E2lMoDfykspBMgYgM_bl-_IrxL0i 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-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=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406210001 X-Stat-Signature: kdiueawguuix3myh6sta3yoewbcw1rya X-Rspamd-Queue-Id: 6071940010 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1718929622-329842 X-HE-Meta: U2FsdGVkX1/MRVvjMAIisEep0fpo+3IgVj2lSETxwMvPrBx3XielVWnx1yS87Go5Bqm6STMLMduIIzD5CaC0mgCE4IeCmx6f7DPnGppRWAUBfirezGl45qFfZUf1bcy/JG70TqQzVm/Cj6LL78RXQOmrSCAdlIcQr4HuNZ4GHihbhawy7Ous6UdHRWI79MJBw5ct/4zCh3aWDvBoKjkk0zI8M4+zs099U6Q9imy8G4g291ZOxIMAcVS+3ZWlMZ+smnUpziBj36UQbDBXPZEykQeptx182QW83VCoYRZBYDIE2N1aZw5Sx8j/UqBgwJ2kV5/Z5nA7WRAcHnAYfiy5H9DZ2pR3u9BxEHAkA5501Ryf8PZTQLea/MR1ZHvW6aYNmpDEN/+riCPrpJAn0NxJumbv3KGKAXvd91hIqKmn2wyZGlTRJ5xG/EygYd7md0WnRKIQmUK8RlxSWSS+/xXTbprpTK7xkbV51IPz3G2DwrQya8hDQOQtp6/1c3k8K6/+YNf3jhDub0BAbKT/HirRstCeZs1bNR6SqALjIahORWxxkGbJhVoo9XnoElfdTngLkOzVEzXRMhJ9knHBSXy0LXWVdMXwaPMnzo0T+/gnj33R19TztzXzmHdXquXdiuhkfOOct7LnxnuDfdSD5TRqy4n2vUwhZPgNfEm8/H0aN73FYz81bzkqjeuIw8H3vY5tWi1gJ5u2ZLJ/+bWbZ+wAp/vg3aFZbBnJTuhggtUaII0o3GsAVFDI1+t1F+Uub7QL5QCeZGhKE1X/fuJMao2Fh/lqQZ3nd5P1s00N1/+dFTWgcoU3tli5T5GXUmBsJsh+SsE0dho00Al8vcFxlS+6lMe34O5FDcqs9NaK8M3HJ6UbC8bkbDX+BBRQZs9yLoh1lJKHY5bRJe7E8pNfHSI4MedB9AUoJmh9WRJ8bwVMXD/ooVi8orwYr/4BgY8xc16pRdJQXcxAvsyZHCEaWDX JgYK+/mk JCLGzOq/luouCC1HhSnc0Xuoeu731Ecwqrv8xmStJEqYPdF4toYj0mHhR+TJSE8oqFoB8PbP5KquL4J5hXGJu/McCgG/TaY9boolFEbUrOjMUN0w3XPdDUi6BlayhU3v3sS7+X9ADqPe+Mf9WH0eNjSfFh/hUXEl8oKCLGDW5+f5nPvBKljg6g4CwTQhj46i25TMW4HVfoNOtoHWBTthvdosZDxNrkeKbyzpwANFR2+sEXyAOzJHuZcWhHc3PjIxGrE4goneRn2IxEG6eUP/RsWPchs2ETJa3jqiqfXnMb5XnSdkEuEKtVKnqhnP5qEZDuX3GJllm5u8GFsLn+hlYLxkaNlcMoLD+/cMhMDRUquM9juQcPpQtKV8lUfMec2dnSvNFfLl1NEDnSLMYKl1PSP9W8A== 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: 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