From patchwork Fri Feb 2 12:30:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13542890 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 88CC4C47DB3 for ; Fri, 2 Feb 2024 12:30:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 666546B007D; Fri, 2 Feb 2024 07:30:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5EF0C6B007E; Fri, 2 Feb 2024 07:30:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4906F6B0080; Fri, 2 Feb 2024 07:30:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 296406B007D for ; Fri, 2 Feb 2024 07:30:44 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id BAB74160F89 for ; Fri, 2 Feb 2024 12:30:43 +0000 (UTC) X-FDA: 81746797566.03.35B78CA Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by imf30.hostedemail.com (Postfix) with ESMTP id 93A928001E for ; Fri, 2 Feb 2024 12:30:40 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=flygoat.com header.s=fm1 header.b=mNL2+pa4; dkim=pass header.d=messagingengine.com header.s=fm3 header.b="C q4Hswe"; spf=pass (imf30.hostedemail.com: domain of jiaxun.yang@flygoat.com designates 66.111.4.28 as permitted sender) smtp.mailfrom=jiaxun.yang@flygoat.com; dmarc=pass (policy=none) header.from=flygoat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706877040; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PkffIQ/TwdfU+2w1YXK1H3DJt1XQppKKQHpkyIAY8Jw=; b=IAUf9Ki12+lQIgNX18S+ZN8zQg1NUaXBZdDYkmxjXhUNG9K7mEyrj8TFaCXKRLtAlSa10h EH49sA9yUtblXRc+9LX59t+/2YRExOleXF8oRSRdLF2D5QPKsPkXbVIGi3BzjFR6HiblmM NFnXRdhInMoCC/8SGoZAPo5GMb8k1LM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706877040; a=rsa-sha256; cv=none; b=p0Saa3Fs5AzvsO1PS/gRq7C0mu902A1wrtfXvSitowhYXx/hanXiESCaic0eC6m8394uZg NXhi7y535v67mzjeOTCXqMk4mTJxQ6OMYA66WoLohQty19HEJr1CGfYeV1zn+wKHHYOU8W wrrDTLIJA4q93aVP5nBeQJvbDETQX24= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=flygoat.com header.s=fm1 header.b=mNL2+pa4; dkim=pass header.d=messagingengine.com header.s=fm3 header.b="C q4Hswe"; spf=pass (imf30.hostedemail.com: domain of jiaxun.yang@flygoat.com designates 66.111.4.28 as permitted sender) smtp.mailfrom=jiaxun.yang@flygoat.com; dmarc=pass (policy=none) header.from=flygoat.com Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id E94335C0180; Fri, 2 Feb 2024 07:30:39 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 02 Feb 2024 07:30:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1706877039; x=1706963439; bh=PkffIQ/TwdfU+2w1YXK1H3DJt1XQppKKQHpkyIAY8Jw=; b= mNL2+pa4mBLckcf1YJNeLqeEfEkNIjSaMXoe0/FrLp02SzGJ1t3KLW7TQO9OrUXc gptTiPkf6xEJzcFsrJmmaP3fCsUyMqC7xRA+KTwybjnLjZRd0HzgwV0Hpw2bMevY DQ+bVp6Wcbe2sKmiK7UhkyRCrq1BPPCVpVdSbfPG+667OCbV20W7ydPsxLBgVJMH PVwxt+msm8xw2LScDcgmsw9zYJAtlnk2NZIT8KBu45qMK6XCj9Zu+luAq6INNCTz MKRctK4ygm6lXXS8eruWRjzvu8IRq6ynqU9WCHZjFBVUj/OjDLAgRPoGsOVl8MQv ymUfDDIqKWIrUCROGYDowQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1706877039; x= 1706963439; bh=PkffIQ/TwdfU+2w1YXK1H3DJt1XQppKKQHpkyIAY8Jw=; b=C q4Hswe3VCvFGloX8BaUea0BX+Tdp6jIWtdo/NcLMOZ56e2czWHNGBPkiuQbNdzBb HBcnE/O0bfvlN2FqY6HlgqPif8XK2+JNKeADBQsfNLfGp3S7Sp88DXOuv7KROL1M qxYc/MyR+MFHX78qRaPRY1BTHlQgtAwnrxD4cVxCo6jpNlPMqWNmYWKx0HxbUh3V wtwSxtMqXbBHWYzIW6RDV58pXcBTsqQEVKXe3gt3wkwFWhOl69ipCtLw8ErunLPu rjLwCcAM/gYCPYwRX1+qpa/wHGqP1JVs4qH6fUfdd60GVpbNtxrx+5sCKB6OCqeW pPmUmusVQfxGge/Nohhaw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrfedugedggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeflihgr gihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqne cuggftrfgrthhtvghrnhepvedujefhfffhveekhfffkeetvefgteejkeeutdduieehieeg feejtdelveejtedunecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjihgrgihunhdrhigrnhhg sehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 2 Feb 2024 07:30:38 -0500 (EST) From: Jiaxun Yang Date: Fri, 02 Feb 2024 12:30:28 +0000 Subject: [PATCH v2 3/3] mm/memory: Use exception ip to search exception tables MIME-Version: 1.0 Message-Id: <20240202-exception_ip-v2-3-e6894d5ce705@flygoat.com> References: <20240202-exception_ip-v2-0-e6894d5ce705@flygoat.com> In-Reply-To: <20240202-exception_ip-v2-0-e6894d5ce705@flygoat.com> To: Oleg Nesterov , Thomas Bogendoerfer , Andrew Morton , Ben Hutchings Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, Jiaxun Yang , Xi Ruoyao , Linus Torvalds X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=1379; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=uKuLCoMYm7TN/5FDEmNqhpyC6JKJvRlQkX2qQKN8ZTg=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhtQ9D9I5oxxuhtd5FaqYPUoS1m9SED32vzE+yratNz1t6 f17PZwdpSwMYlwMsmKKLCECSn0bGi8uuP4g6w/MHFYmkCEMXJwCMJGpQQx/xT/dPrVBSu154PLX /HJvTZJnd/7847ilbPm6i5kqQk9unmX4yVh5i+20gXjQviW/jx/ZZs6cUhVptrg1LabUvf/G1MP JLAA= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 X-Rspamd-Queue-Id: 93A928001E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: qrm66w9qga38sopjmp5qi9e44hwnpinr X-HE-Tag: 1706877040-182947 X-HE-Meta: U2FsdGVkX1/3IdOH0u19/W8EWJWjfglRmHn0XrmX4vQ/QzCBgff4m64DpUKKfwMxaqmGKvkJGmjF+kJaMCJxgYk0PpW+0ttRlTqYJxZW8CI95wXNWE44Q3A7Gw1ZJTtBaF26Iz68xfFZ8flW5Fup4qPexsBOeyMHYNS2E/m7DGWQrq9z6eOUOuwr1QlxgL/mnGR5udF/KqWfYgDuXKii/pnZmikHV0LlzVSaU+7xUMyST9XY5YVrP8kpZBVW/5liJp10GxvZ2VP+oXmExYOg/58Pbjee0+i7Uuj6PUpHUlOt6rffX3rrwUJNWTrA/+ZdDrH1zXstnsa9URnmJxxtEN+P35d27P9aFmoap2kBh+P/XmLvYjAjajDr6AX3rFRfs2rjiu3dVieQ8sDsasdN8wqu5yXIkVHWxwdeSJtqKlo3W4uQbb5ybuTAdunrjmIH7zkktj7d4jRchfUvNa309y+OeV2jv/JR9BQY+q1ySAJcKWxrwq5rSWhG3hLCVwTPEqM0dj9VezlHvAtAE/QRkwavn3yZP5okdK93P81v9MD3Mh7Nmbn0FVJ0YsAAGgKLlvqCS1cG4ykybJQXHCHqJ6v4NF6Ypq9xua6iAd5mXTNfogi5Q/uUwfLTUkrwVb4btwUjYtYY+CaQXcDn+AU7Wc+QX2/l82IRwVt4Wz+Hx/nBON7jVN3elchQNUvmxT4atldyBush3/ZvucX3Lj2kXcVQCtwxRm29pHlJtdl7lKfJz5ep3t3Qly6+hPf2lhvp3fOqBC0ExzFJRQbYLTG5ASA+ux1TG9ppAAbZpRq3G5vb5N3xpRGq2qu849WUzAfz0Sf13ThrpCyuuBy6PEmnOVViiUBJC/gFEaJH1xyEv410PW3Buz53X6OfbeOw6dzJONZ/ztqp7dgb0I7sW09FkJC6a80iNQ6ZM85venIs9xKtZASNGWDvo9VpGsPWRiI5qaAB7h+ngL0nUfiGEOp Im5kYsei xUPUW30wZk5wM8RA1v4Ar0XYoImXtKFbn4dqMRd+I5UtxG0h4On7eS2lCTY3zjiB2xPMuaWelY3KkgKB+n+H2gqTHvS9Wr3jq8u0BHZLb7Cq8+W41s5QasTesY1vEJzKw1utnxtTiNIopcoeqiuzoAvws1slmRrQL/MuMd/MwsdVqw2m91qY8hbYnLb8WwR7cyhTffRharYzn2fH/CHbsHX2gCNGIBKCBGcYCOwku1kiyfXJUYDUiaSwHpuScWxZ26ftdh8iIzFHrBFsTC2S8O2U3+DxyKVI+WQXzWHgNmuzy8e2BsVbzQKkHP5LBWPRMmDLFf1S8dq5kR8dMR3acsZMWo3BctBrkftJuKJgQdtwmk22hUBV+70MNV7rfGK40I0sW7KB3s/R2fS0OhC9mzbkFWpVMFg2EH5w7IS6Y5GFKHstIXdgIFi5TFrEItobjDA43 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: On architectures with delay slot, instruction_pointer() may differ from where exception was triggered. Use exception_ip we just introduced to search exception tables to get rid of the problem. Fixes: 4bce37a68ff8 ("mips/mm: Convert to using lock_mm_and_find_vma()") Reported-by: Xi Ruoyao Link: https://lore.kernel.org/r/75e9fd7b08562ad9b456a5bdaacb7cc220311cc9.camel@xry111.site/ Suggested-by: Linus Torvalds Signed-off-by: Jiaxun Yang --- mm/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 8d14ba440929..49433612444a 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5481,7 +5481,7 @@ static inline bool get_mmap_lock_carefully(struct mm_struct *mm, struct pt_regs return true; if (regs && !user_mode(regs)) { - unsigned long ip = instruction_pointer(regs); + unsigned long ip = exception_ip(regs); if (!search_exception_tables(ip)) return false; } @@ -5506,7 +5506,7 @@ static inline bool upgrade_mmap_lock_carefully(struct mm_struct *mm, struct pt_r { mmap_read_unlock(mm); if (regs && !user_mode(regs)) { - unsigned long ip = instruction_pointer(regs); + unsigned long ip = exception_ip(regs); if (!search_exception_tables(ip)) return false; }