From patchwork Tue Jan 31 20:03:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13123342 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D9E8BC636CC for ; Tue, 31 Jan 2023 20:03:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oIVjXvlUXU2Mt4XfmQPzf6DFquEL8jmaW4Swae/z3F0=; b=WePKOj0Yd8FYHb 5JyF1DN2twzT/wNlEkdDeqTSUYTmeOFbyEjLIsuvQRcqQ6AwRe48qWmvoKAUtYMrzY208VzrZuRcE SV66r7Mdh5KUgGVDky/Pckoia30T3RcO5BtDguruciOs8525P0b64m8XPIVJPEoc7PjvRpn5eF8Zw ljrZ7eo9/qzBlt1MyMAkzA3KFyKNWuF7UfOQSPKgfUjVLnJnTeMJ6L5vSLtNCMX4pdTkBk8dAXjBu roSoaYtZQnUdeA5T7esOw0PUCiDdZoUphujlCzgdluQKaTV86kMLUx4V8lzIguB3QbkULOf8xoQDp X97EyD+JNsHT/hc14avg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwqt-009CeY-BO; Tue, 31 Jan 2023 20:03:35 +0000 Received: from zeniv.linux.org.uk ([2a03:a000:7:0:5054:ff:fe1c:15ff]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwqq-009Cco-Ci for linux-riscv@lists.infradead.org; Tue, 31 Jan 2023 20:03:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ED6R08GbccKYIIX9kXT549IPtW4L7cqF2AXMvdmRFj4=; b=iNM2NyBX9qKzLnSjicxOotEmdb mPwBfHxw1JcxbXjAmuQzkUPkY076SeFW9sb+OEtR3wdxggD/OHl7HF+zCRhEDKyPAy7wtUQ04tVp3 8nBqtkHhKsi9Xm58VZesKGNtjv7L3mh0zN0MWsZfar40SOh3yGMBypMpwAVllpvQK7XvGiD07RbVx KLUSciQqkdXkPxJs6MuDmfTwzuqJz2o2Ds1f0vjiLr7dRyMt1d7fXghuodLsn7lPVjZV7vudP5qG0 Z6gCcHCEbZ5W/gjbvjr/2oKDctHKl/D8ra0DVYtaeptbIhqPn6qSCGk3NWvfxTtqe3xyyb6FoIWpa Zk9x+jrw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1pMwqm-005IlR-0f; Tue, 31 Jan 2023 20:03:28 +0000 Date: Tue, 31 Jan 2023 20:03:28 +0000 From: Al Viro To: linux-arch@vger.kernel.org Cc: linux-alpha@vger.kernel.org, linux-ia64@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Michal Simek , Dinh Nguyen , openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org, Linus Torvalds Subject: [PATCH 01/10] alpha: fix livelock in uaccess Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230131_120332_447100_CEE6B6E7 X-CRM114-Status: GOOD ( 13.44 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org alpha equivalent of 26178ec11ef3 "x86: mm: consolidate VM_FAULT_RETRY handling" If e.g. get_user() triggers a page fault and a fatal signal is caught, we might end up with handle_mm_fault() returning VM_FAULT_RETRY and not doing anything to page tables. In such case we must *not* return to the faulting insn - that would repeat the entire thing without making any progress; what we need instead is to treat that as failed (user) memory access. Signed-off-by: Al Viro --- arch/alpha/mm/fault.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c index ef427a6bdd1a..7b01ae4f3bc6 100644 --- a/arch/alpha/mm/fault.c +++ b/arch/alpha/mm/fault.c @@ -152,8 +152,11 @@ do_page_fault(unsigned long address, unsigned long mmcsr, the fault. */ fault = handle_mm_fault(vma, address, flags, regs); - if (fault_signal_pending(fault, regs)) + if (fault_signal_pending(fault, regs)) { + if (!user_mode(regs)) + goto no_context; return; + } /* The fault is fully completed (including releasing mmap lock) */ if (fault & VM_FAULT_COMPLETED) From patchwork Tue Jan 31 20:03:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13123363 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C588BC636CC for ; Tue, 31 Jan 2023 20:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uodmNwo9d3j+07tOQi7BWojyQJxZ/dgqkTwKmMXgzdc=; b=oMuxAW7EZnPnKY +SRXGS5qoHgjY4tL3QGdlKoPbWTffnaSPoZIKBDvIUcotc7t3CQbW/CnHgtt1CywZxO6Lmsknox/Z vkZlhONQ/CdH0fkz7aO11EqmVWngb+XCw+zA4WKxYwlv9sZkgwZ10/XeHhVHm6Z1YS6878VWMOLiM O78O65UjFQz7wyM3D11zIE8ghx9ChQBLxiNCKu6mjB872imU8+h0S76bDzIF9wuyiBb3hKp6IaS8d N09o5Khw2yeZRi8zTkxtYGIVJ4zq6P6cxDr9JgInM9cy/r6WYvP1u4pYKR/elLBoG2SPCbbsZqFke gwmeyKs9xjVLyLLcm+Cw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwrO-009Csg-CX; Tue, 31 Jan 2023 20:04:06 +0000 Received: from zeniv.linux.org.uk ([2a03:a000:7:0:5054:ff:fe1c:15ff]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwrL-009CrN-6t for linux-riscv@lists.infradead.org; Tue, 31 Jan 2023 20:04:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=NiUEF1IXJzgFv+aygXF4aq+5ipqUNm7thH541I6WfmM=; b=qrX5aIC933LH7FY3NYNDGqcac3 J4RLy9ITM/ESnjrkRtt+ZQZJOfvq0nIQwfvgMBcOTyfnzTmsJv84XzPORhXETQTOoOLXXWaMPU11g wWvVQAG9vO2sKKmMVQG8WX8stYodaZrmsCPGFrGtLUFejEjbL5wY0E4oFziMjX/2m0AbZQSq8/0uo hwlfhKenawZVF2SiZJ4iM3vie9sd4lhkhYK7rAPK7z2zUPYejBHQbpjvBB2tcRo3dqkR/nIhuM5/c 9ssUOIlT1HzcYif+UgzMVS3T5gmkNtW3FdxCDLxJ0wrOJVILV80fadrELvoH7vDx8WyS7SD6axv1Z hQer2gQA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1pMwrH-005Ilf-1l; Tue, 31 Jan 2023 20:03:59 +0000 Date: Tue, 31 Jan 2023 20:03:59 +0000 From: Al Viro To: linux-arch@vger.kernel.org Cc: linux-alpha@vger.kernel.org, linux-ia64@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Michal Simek , Dinh Nguyen , openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org, Linus Torvalds Subject: [PATCH 02/10] hexagon: fix livelock in uaccess Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230131_120403_274529_C5D76CD1 X-CRM114-Status: GOOD ( 13.49 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org hexagon equivalent of 26178ec11ef3 "x86: mm: consolidate VM_FAULT_RETRY handling" If e.g. get_user() triggers a page fault and a fatal signal is caught, we might end up with handle_mm_fault() returning VM_FAULT_RETRY and not doing anything to page tables. In such case we must *not* return to the faulting insn - that would repeat the entire thing without making any progress; what we need instead is to treat that as failed (user) memory access. Signed-off-by: Al Viro Acked-by: Brian Cain --- arch/hexagon/mm/vm_fault.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/hexagon/mm/vm_fault.c b/arch/hexagon/mm/vm_fault.c index f73c7cbfe326..4b578d02fd01 100644 --- a/arch/hexagon/mm/vm_fault.c +++ b/arch/hexagon/mm/vm_fault.c @@ -93,8 +93,11 @@ void do_page_fault(unsigned long address, long cause, struct pt_regs *regs) fault = handle_mm_fault(vma, address, flags, regs); - if (fault_signal_pending(fault, regs)) + if (fault_signal_pending(fault, regs)) { + if (!user_mode(regs)) + goto no_context; return; + } /* The fault is fully completed (including releasing mmap lock) */ if (fault & VM_FAULT_COMPLETED) From patchwork Tue Jan 31 20:04:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13123364 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 23C37C38142 for ; Tue, 31 Jan 2023 20:04:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lyajDN0HYSW5WmLS6AvcD8sXDm0uJk8Jfo6nlkCurhw=; b=cLpLzEWzTt4ZTn em4gMoBGNLdNEDqqmLr/WX9ay/GWYOq1AZ2PJZIlpXScNNrjq4m20CTJlW+IrN+x99CmMzr+RYb8N DeJauAuggzRhXPAhsLVM7GA8RKFHUi8L4y9N/ir+1fDm4RfqR6b4ScIdjpF+naWMm29uZAjROxq7S pj+7CAyDZpE5ADbAoNRPEn3rXH52VwgI/Rt2rQiq0MTFgUVycPBLtyiVP0n5Mn3vcyd3YS+DJeWrs eWyYeKOpvRSFaa9c7ewpVgkdaEzCoSehlJ7mWDHb3WyuvDtEQqYVDTPZ7kpZj73ZZ9T035cdv9Nqo N4iPBW8O0euYGiZGamog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwrq-009Cyg-Bg; Tue, 31 Jan 2023 20:04:34 +0000 Received: from zeniv.linux.org.uk ([2a03:a000:7:0:5054:ff:fe1c:15ff]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwrn-009CxR-W6 for linux-riscv@lists.infradead.org; Tue, 31 Jan 2023 20:04:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Bl5iUXqmXEOZR8ifG6HKyF4x1jQ0mIa3D3l9XR4PaTE=; b=T1pWKmZWPHuHO8Jyn7S5P/zto+ UZfPKBZyRLG27ebQFQOn/fWzfDlIAMxY5HnpFAsDM33oCZ+/Oqy97hkFrd/ty/TtBVplGI9UlZkpc fbW++/mewnSYFO9jvmdzRomSgggz4wlhTLgqvJVMyFQJo7JNjGdbYjrvvOCf8fp0gxg7cOp7xtr3r ESdWCs27/xj5QzXKLgnJBxqhbIe9xDzRoYllJ//kxI1dcU2VM9HH60bLK1f0Ri53IBKDWu4a9kqmF F2PtXGW3wiF+E43i3v0Rvv/Ti4b5qXLpcgoQxKTylUS/49rUu8IB+gb4J12gNq/O4ec6MWulnmUSJ YSws+EYw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1pMwrk-005Ilr-0p; Tue, 31 Jan 2023 20:04:28 +0000 Date: Tue, 31 Jan 2023 20:04:28 +0000 From: Al Viro To: linux-arch@vger.kernel.org Cc: linux-alpha@vger.kernel.org, linux-ia64@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Michal Simek , Dinh Nguyen , openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org, Linus Torvalds Subject: [PATCH 03/10] ia64: fix livelock in uaccess Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230131_120432_045249_2E0AB79C X-CRM114-Status: GOOD ( 13.39 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org ia64 equivalent of 26178ec11ef3 "x86: mm: consolidate VM_FAULT_RETRY handling" If e.g. get_user() triggers a page fault and a fatal signal is caught, we might end up with handle_mm_fault() returning VM_FAULT_RETRY and not doing anything to page tables. In such case we must *not* return to the faulting insn - that would repeat the entire thing without making any progress; what we need instead is to treat that as failed (user) memory access. Signed-off-by: Al Viro --- arch/ia64/mm/fault.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c index ef78c2d66cdd..85c4d9ac8686 100644 --- a/arch/ia64/mm/fault.c +++ b/arch/ia64/mm/fault.c @@ -136,8 +136,11 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re */ fault = handle_mm_fault(vma, address, flags, regs); - if (fault_signal_pending(fault, regs)) + if (fault_signal_pending(fault, regs)) { + if (!user_mode(regs)) + goto no_context; return; + } /* The fault is fully completed (including releasing mmap lock) */ if (fault & VM_FAULT_COMPLETED) From patchwork Tue Jan 31 20:04:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13123365 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5ECDDC636CC for ; Tue, 31 Jan 2023 20:05:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ioh4fLYCT+ZmxqqxQDOT4iUaPNME/xxMsYb6rZb0TnA=; b=zDxiO9Nv6IZYf3 e84KPgDzqtnyMtcG46DvVfQGWdamv7H5dL8QLPrlFGYMD2bj88gHIO9nCuPYUziXXc2WPvXYXIeUc kWxsjYf+3DNIKXAt3S7o5qCMFc0iD3dZkETrOb+qT081PUDFxMdUTKtCAN9WoJcvhQbowYU4+ksif u5XavW/dg+TCFg1GP4tVAQ7aTl1WHnvqagvbTFFNsjfte0uMO3t790JscqfzWAP6hJJF8Z51lcUmf VtNaXy0nti30rbC63YemyN/+34jKtiZSchm3Y41GSsmpPQISZ48CAQMgyuz+5zfp6llWAIvggxlbb OWQtavqFD04NtoMpbATQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwsJ-009D7h-2X; Tue, 31 Jan 2023 20:05:03 +0000 Received: from zeniv.linux.org.uk ([2a03:a000:7:0:5054:ff:fe1c:15ff]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwsG-009D5v-Kr for linux-riscv@lists.infradead.org; Tue, 31 Jan 2023 20:05:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=6IKigZkqFBsGpbA9ajZ2Iw9VszpR27B7CG3/bEQJDxY=; b=eqmvDT91wCunq2V0AGR+ix+Vs+ YV3cRNHbq+Oy47qp3ylEH4Hx8wSoOkaEB/q4RsfIimm+3zp2sK8JZ5/AkCaGprUFjL3LaVBMyP2wb ctSr4iPJXbxHiVykZr70RsmiAkRaZ3BbjqgAuai0uhpcmiS5vwLi62m3UYSrqalvn/nZqUk37rCq4 hoDGKkp6jhvk9o+s3m9EWdmlljeMqELxaKTo/d3KRlTgwkcfslaVe+qAu9wCEu9cF6JTtjDYu7z4P gffgyZDBbqPaD23gHSwlTUZ72eJwvSErKw+PO7gny0NokmaAPqBpro/zvO2bxOQO4z0uezIuymel6 sGcFpM0Q==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1pMwsC-005In0-1J; Tue, 31 Jan 2023 20:04:56 +0000 Date: Tue, 31 Jan 2023 20:04:56 +0000 From: Al Viro To: linux-arch@vger.kernel.org Cc: linux-alpha@vger.kernel.org, linux-ia64@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Michal Simek , Dinh Nguyen , openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org, Linus Torvalds Subject: [PATCH 04/10] m68k: fix livelock in uaccess Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230131_120500_699056_39054637 X-CRM114-Status: GOOD ( 13.60 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org m68k equivalent of 26178ec11ef3 "x86: mm: consolidate VM_FAULT_RETRY handling" If e.g. get_user() triggers a page fault and a fatal signal is caught, we might end up with handle_mm_fault() returning VM_FAULT_RETRY and not doing anything to page tables. In such case we must *not* return to the faulting insn - that would repeat the entire thing without making any progress; what we need instead is to treat that as failed (user) memory access. Signed-off-by: Al Viro Tested-by: Finn Thain Tested-by: Geert Uytterhoeven Acked-by: Geert Uytterhoeven --- arch/m68k/mm/fault.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c index 4d2837eb3e2a..228128e45c67 100644 --- a/arch/m68k/mm/fault.c +++ b/arch/m68k/mm/fault.c @@ -138,8 +138,11 @@ int do_page_fault(struct pt_regs *regs, unsigned long address, fault = handle_mm_fault(vma, address, flags, regs); pr_debug("handle_mm_fault returns %x\n", fault); - if (fault_signal_pending(fault, regs)) + if (fault_signal_pending(fault, regs)) { + if (!user_mode(regs)) + goto no_context; return 0; + } /* The fault is fully completed (including releasing mmap lock) */ if (fault & VM_FAULT_COMPLETED) From patchwork Tue Jan 31 20:05:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13123366 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0DF8EC38142 for ; Tue, 31 Jan 2023 20:05:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QVqWv8GOaaF5LxE0qSzNmdVKWNF4luZ0RiENRtUfT+w=; b=yH838NPFt4SgPE BU8u73PJVMBxruNbbfn2NG8tkXgQsj+T+3qTJc6PiTBHkLFS7ZFFY7+RAif90WUaF+/kV0zda+Vdq gc1jQFfio0yTlBnRXsRZuPpgr6fiWKbHJWV/jv+LC4oZt+WXwH9OnpL1oUasV4g9A/PYkbpmU3l7v 2Pw3R46M+bhMan3gzWVr8w8ECJaAYoLQa8Lo0xxnCgW55UVZAvMykYrepUi8IktXRFcwyaQvjSTxO YrsVZDbF2ZrPv6LZar7tmfy02x0FJunsOGgM2Oz/x3CojSHz1ryk2GOzJyFSCYoNDUDDl69WVdJBH uALFXfuA/4euugJpq86g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwse-009DGT-Af; Tue, 31 Jan 2023 20:05:24 +0000 Received: from zeniv.linux.org.uk ([2a03:a000:7:0:5054:ff:fe1c:15ff]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwsb-009DF1-NL for linux-riscv@lists.infradead.org; Tue, 31 Jan 2023 20:05:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=3kTCQJAzvtQgF+3xVESNHSwfzkDuXB+SbkK+fGW9zGg=; b=bGYu2JdcFxfcNz9N9WK6QGtxFH n5T+8OVqLi+TTCCa+E46lH+Kjx3zHOAPxbgy0ZP7B2oy4PZSg58DZr+cutBNk0vUoPEtWyk+A/Jh/ rVDifq05ryKDxsQtc00avshK/j20/pEkz2hx8GvIOWK8xAafyH15128EgVU7ZBuxv6QK1RQmr1wYa QWwyIaTWTrCHCT+ycDdW8uW/ZJSQNVhdTTDu4uoUrr5VWEe5EMZUKN9u3QjNZREUFwa6DO6QRqi6M iIOGix659cEq+kGzhE3+5ZabtWHALGzDuufXwbtgR6vd+tfpkSmbd4VYgDLWmHy5Llp9+eE11N20y v5D3jftg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1pMwsX-005InD-1o; Tue, 31 Jan 2023 20:05:17 +0000 Date: Tue, 31 Jan 2023 20:05:17 +0000 From: Al Viro To: linux-arch@vger.kernel.org Cc: linux-alpha@vger.kernel.org, linux-ia64@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Michal Simek , Dinh Nguyen , openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org, Linus Torvalds Subject: [PATCH 05/10] microblaze: fix livelock in uaccess Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230131_120521_782175_24FA9CF3 X-CRM114-Status: GOOD ( 13.68 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org microblaze equivalent of 26178ec11ef3 "x86: mm: consolidate VM_FAULT_RETRY handling" If e.g. get_user() triggers a page fault and a fatal signal is caught, we might end up with handle_mm_fault() returning VM_FAULT_RETRY and not doing anything to page tables. In such case we must *not* return to the faulting insn - that would repeat the entire thing without making any progress; what we need instead is to treat that as failed (user) memory access. Signed-off-by: Al Viro --- arch/microblaze/mm/fault.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/microblaze/mm/fault.c b/arch/microblaze/mm/fault.c index 5c40c3ebe52f..32d9717039ba 100644 --- a/arch/microblaze/mm/fault.c +++ b/arch/microblaze/mm/fault.c @@ -219,8 +219,11 @@ void do_page_fault(struct pt_regs *regs, unsigned long address, */ fault = handle_mm_fault(vma, address, flags, regs); - if (fault_signal_pending(fault, regs)) + if (fault_signal_pending(fault, regs)) { + if (!user_mode(regs)) + goto no_context; return; + } /* The fault is fully completed (including releasing mmap lock) */ if (fault & VM_FAULT_COMPLETED) From patchwork Tue Jan 31 20:05:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13123367 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 64D90C636CC for ; Tue, 31 Jan 2023 20:05:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Anzrbxi+k6QfgrdhT4LUp57o/6gMeugJUoAR5dZCYm4=; b=u4ZWTGGFYtuRza mUAisO74utTXk48THVjRokptTbWK2pFiwRGNTopgwj7wE4sAYf73y77q7LShbyjhb431c1WUMdeC/ 3OScaAvqJXGmbGEK/Jlih7435YCazv+hM1eJEgtEVv1fPY4le+rTIVOcVKaRQ3nxVWZTCgWAEaMCU iylT6bEW8kPPkoMBDNLIjaMRd4XNVLiLDtXEtzyKDYL4PZ8aaFO3tMh8X2xMburAs9CfRZnR5CBdn tjQRMdZjDUl2ZZvMlN8Oh6J2xy60uUsJQ2IHKTxUHvtkbgk6itfZONCBZHf7EVUjnfPYTao/Id0TB i8ad85qgRnmc8VGkl9UA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwt3-009DQD-VE; Tue, 31 Jan 2023 20:05:49 +0000 Received: from zeniv.linux.org.uk ([2a03:a000:7:0:5054:ff:fe1c:15ff]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwt0-009DOP-Ft for linux-riscv@lists.infradead.org; Tue, 31 Jan 2023 20:05:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=wVcE+3BmnOfE/NwR5UjnA+ry4zfP0RI8olAVTcvgEUs=; b=Ct+tFykDR6lyUvgdiXaL+wDIv/ VFKiuRPBE9+1rOFXjTFIBjHI/P55UQYeegg4ROhJbh7VJrHAYz6EFq6N+X9LGTZvO8s+OvI5T7m9d qmQqtM6XOtNklHUYyAfzY0h/wRwNGPbnRNpVSNAxSoBo9MMFwyj6zvWApQgTlg7wfaK0w40U8kAwL tZaSXHiZmLA8SHXOzUDL9f2Pp+sChQqZRPkIOLXDx2QoHern1VKKeXIUcTcuvVj0N/fhBl775dcOT GOTmusZ8rUu+c3bWVqkzxdmhQULmaNnZH4EqUIU+DRw/mxAc8nmXIKaaBdqT5RIwNXWNYPVPOMzgN LnAE7PlQ==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1pMwsx-005InU-0T; Tue, 31 Jan 2023 20:05:43 +0000 Date: Tue, 31 Jan 2023 20:05:43 +0000 From: Al Viro To: linux-arch@vger.kernel.org Cc: linux-alpha@vger.kernel.org, linux-ia64@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Michal Simek , Dinh Nguyen , openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org, Linus Torvalds Subject: [PATCH 06/10] nios2: fix livelock in uaccess Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230131_120546_543339_1DF06E5D X-CRM114-Status: GOOD ( 13.58 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org nios2 equivalent of 26178ec11ef3 "x86: mm: consolidate VM_FAULT_RETRY handling" If e.g. get_user() triggers a page fault and a fatal signal is caught, we might end up with handle_mm_fault() returning VM_FAULT_RETRY and not doing anything to page tables. In such case we must *not* return to the faulting insn - that would repeat the entire thing without making any progress; what we need instead is to treat that as failed (user) memory access. Signed-off-by: Al Viro --- arch/nios2/mm/fault.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/nios2/mm/fault.c b/arch/nios2/mm/fault.c index edaca0a6c1c1..ca64eccea551 100644 --- a/arch/nios2/mm/fault.c +++ b/arch/nios2/mm/fault.c @@ -136,8 +136,11 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long cause, */ fault = handle_mm_fault(vma, address, flags, regs); - if (fault_signal_pending(fault, regs)) + if (fault_signal_pending(fault, regs)) { + if (!user_mode(regs)) + goto no_context; return; + } /* The fault is fully completed (including releasing mmap lock) */ if (fault & VM_FAULT_COMPLETED) From patchwork Tue Jan 31 20:06:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13123368 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9CCAEC636CC for ; Tue, 31 Jan 2023 20:06:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=p6cRZpvCyqir0T860hshVhXNrBKe2FIcdCH6S4ZBwbw=; b=jE1d1QvTEaFWU1 K4KDh0TkIEssbdJhtuPzTDJVuh9pxgi7aMTIchnnzKuVdkjfEuqEY36R3nZ9V8PrZDE0GyH0owHUT nqA/DMz5eGvdQH/jKXsLdnIglPAhItXl3hymzlZ06zv1soQv9Vb+iMckbs7VzeIwKTTNRQ1HH2k95 93mR0pgTZvIF8eU3cMufRFppHeHRrZtiiA4Mf40uvyXuCbNNrF2i4Z9X3mP6m4XDpYjAbosoAZQu1 +IRTWP4kBNIPpUFW99svNT6haPLFCuWcnB9OUcbo148j1hJcEcJFVFVIdiiAwiik8L2y5VoqKwa5Z WCaBffoDLszPTSA7ig6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwtP-009DYB-S1; Tue, 31 Jan 2023 20:06:11 +0000 Received: from zeniv.linux.org.uk ([2a03:a000:7:0:5054:ff:fe1c:15ff]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwtM-009DWZ-SS for linux-riscv@lists.infradead.org; Tue, 31 Jan 2023 20:06:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=VASyJZSBEquFV0KDKoogdy4OX3OzJhAh5o0jO+QEP/8=; b=HB3AztPi+msrmE3oE5yxiRYHVr ykikKMa5v2Yo/giiWWzK4KJyD5/Ga89pUwCA5QwIcEFZBjT6oE1RFuEVpeMiy76e/ZXx+0nL5crYs 8IK4nTQuAawNWyAZkdVLhCPSzC1A/uzuiGDGdxxpBOFsX7lUljEbBv6ahdNY643XjTRayt1YFEoJx 2sQZ3b5XcI1+dhT9RX453RW2gqZWp14s31ix2dzgEhP3KVyyOxoPEN9O1p0Xp124Si6XBthNYbFUh lczTWd+6ntJSifvArW39txP0ZNkdkGGYFRV1xXxHbQIvUoxSo7pon5BnAUMC8WjMHKxggfzsDaq8a E+6hb8kg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1pMwtJ-005Inr-0r; Tue, 31 Jan 2023 20:06:05 +0000 Date: Tue, 31 Jan 2023 20:06:05 +0000 From: Al Viro To: linux-arch@vger.kernel.org Cc: linux-alpha@vger.kernel.org, linux-ia64@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Michal Simek , Dinh Nguyen , openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org, Linus Torvalds Subject: [PATCH 07/10] openrisc: fix livelock in uaccess Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230131_120608_945800_1D853AB3 X-CRM114-Status: GOOD ( 13.39 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org openrisc equivalent of 26178ec11ef3 "x86: mm: consolidate VM_FAULT_RETRY handling" If e.g. get_user() triggers a page fault and a fatal signal is caught, we might end up with handle_mm_fault() returning VM_FAULT_RETRY and not doing anything to page tables. In such case we must *not* return to the faulting insn - that would repeat the entire thing without making any progress; what we need instead is to treat that as failed (user) memory access. Signed-off-by: Al Viro --- arch/openrisc/mm/fault.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/openrisc/mm/fault.c b/arch/openrisc/mm/fault.c index b4762d66e9ef..6734fee3134f 100644 --- a/arch/openrisc/mm/fault.c +++ b/arch/openrisc/mm/fault.c @@ -162,8 +162,11 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address, fault = handle_mm_fault(vma, address, flags, regs); - if (fault_signal_pending(fault, regs)) + if (fault_signal_pending(fault, regs)) { + if (!user_mode(regs)) + goto no_context; return; + } /* The fault is fully completed (including releasing mmap lock) */ if (fault & VM_FAULT_COMPLETED) From patchwork Tue Jan 31 20:06:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13123369 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D0FF1C636CC for ; Tue, 31 Jan 2023 20:06:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mwZjwACCXB8y3aJIU6ucO/4nnPks86vSDIatawVmxig=; b=BAG56xy40RF8AI vb7I2s4R942D5rpoinkaRDrJ4t+V/x+8JxL4WYWUvDmg7dW9I3ManANo0MiE/aYBSfOmyItqYUyZv gSDqNBZVo+V3OwJyPkuHSIG6e7tt2C2pWcvI9j7+qdm0kQivuHJbDnXjdpbAfc9JEZ3ACqcx9k7s6 d91q6IMUCvQjj7Yy9i4LE9bdxslaMUWSSd6Xr6mu0vpq7RHLP/H6kt36S84xRlhc99UrtgWzh56/T gICiy3DCoXBTTOXJBkhTP4R1mYXDRdv3y1p175+kMNtAesizhOWLbQeccLFBWyXrKB5UNEEYlTm1z ms367MmnqC+sgJ7wdySQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwtk-009Dg2-4s; Tue, 31 Jan 2023 20:06:32 +0000 Received: from zeniv.linux.org.uk ([2a03:a000:7:0:5054:ff:fe1c:15ff]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwti-009Df4-G0 for linux-riscv@lists.infradead.org; Tue, 31 Jan 2023 20:06:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Va46d86eM1Bc2zftK4w6YVIH/9TSKHJFKV1SMXapYTA=; b=wP1rmspskn7rYIm3LIubWz3zZY CX7Pm1fllvuDHdAV0IOAnSDgrsaowkvoRmi/XUYRBrjGq3ixNXrTgSKteSegRq92d4ZSuD2x4KFqN n64Lx21+SSTyHwh9ZQTkuJ5tSwYqU543ckEgA0Afvo3XT8tp2WFfrZADEX/iSevSCRtO4lo4UZKUd uMAnRpLwr7SxtDn29dSzBAsDhDi1jL2v7u6WaHriQRKtfQTLK52Pew4tfOJqXzALx0qtScNMOJCrQ VIm60E7FRBQGzyrh8RI0tkmGD+i2Z8lIe1R/29aG3eeR/81AwwdA+P75WnbVplBNdABD9j2/J2gJM 7+tiSftg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1pMwtf-005Io6-0L; Tue, 31 Jan 2023 20:06:27 +0000 Date: Tue, 31 Jan 2023 20:06:27 +0000 From: Al Viro To: linux-arch@vger.kernel.org Cc: linux-alpha@vger.kernel.org, linux-ia64@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Michal Simek , Dinh Nguyen , openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org, Linus Torvalds Subject: [PATCH 08/10] parisc: fix livelock in uaccess Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230131_120630_546220_4B9EC0F7 X-CRM114-Status: GOOD ( 13.50 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org parisc equivalent of 26178ec11ef3 "x86: mm: consolidate VM_FAULT_RETRY handling" If e.g. get_user() triggers a page fault and a fatal signal is caught, we might end up with handle_mm_fault() returning VM_FAULT_RETRY and not doing anything to page tables. In such case we must *not* return to the faulting insn - that would repeat the entire thing without making any progress; what we need instead is to treat that as failed (user) memory access. Signed-off-by: Al Viro --- arch/parisc/mm/fault.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c index 869204e97ec9..bb30ff6a3e19 100644 --- a/arch/parisc/mm/fault.c +++ b/arch/parisc/mm/fault.c @@ -308,8 +308,11 @@ void do_page_fault(struct pt_regs *regs, unsigned long code, fault = handle_mm_fault(vma, address, flags, regs); - if (fault_signal_pending(fault, regs)) + if (fault_signal_pending(fault, regs)) { + if (!user_mode(regs)) + goto no_context; return; + } /* The fault is fully completed (including releasing mmap lock) */ if (fault & VM_FAULT_COMPLETED) From patchwork Tue Jan 31 20:06:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13123370 X-Patchwork-Delegate: palmer@dabbelt.com 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D93BAC38142 for ; Tue, 31 Jan 2023 20:07:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bNKbn9DDyn8wPRmdaRtAGV/aCLU7Qugbn8mr4tnG8Nc=; b=d/dl1HcWEUa3Zr SMxvtnvNs3UHytzmjP+BJdJq4rcRuync1JKhicV6mYpPKz8e8UdfwjkpK2BaWs9aFr9Ws54zLk5zo lGvtI8y3UsWel7dKZZt7yyY3rsZ7is7myuuKjHJLiFQaozfS2KZDHboScr/9iVCnPPLfFzd2svhyM As95Pl14s78H7d5E5wbGpoCuhALDc1UmR0lgbStMF8y15i1a19++ssWlB4SMlLe+inTU6CM0rcbEJ NItFqs01fUAQfKLj4mPg9boQvePBjVo5O14xJ5z80aZJJLjB8X/KNn1SrJ1xB+o6bAc9WaWsuEC8Z Vz5WRqboIErbwsYGNpRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwu6-009Dou-3n; Tue, 31 Jan 2023 20:06:54 +0000 Received: from zeniv.linux.org.uk ([2a03:a000:7:0:5054:ff:fe1c:15ff]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwu3-009DnZ-RW for linux-riscv@lists.infradead.org; Tue, 31 Jan 2023 20:06:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=nvc6EOOE6Kc37iQ5tEQ7l2xOJqqEJfVCbXPLSTxaEF4=; b=wdY4q/NUsSzoOzzSH9JWxFXi7s Tk1MepTXqcFNQuqsv6PLGLDlWg/ho5Hq7LbS/6/Ozd57SshWTeDBArvFWXDhGFh2BhNX8dBI4LgkO LpJmKqpkO4x5vY1+b9CcqUE0aGIpoyS5qStg8iBjcK+HypQyzzYiPNvF/dOM89WyZgG3dUo1oR8AB ONYs1wDgkd19QVLeBTvry12xY2pe789ERsnyEmEuQrns462tlSiqhjy4E15CVoyugsuWlzfNMig0b a6a88eJ+8ZtJ/kyRgEu6wVtRz1ghz6pXOq3cyUYQcf7ksmGIi6rbK4dPwUT0N6fTylQGUN8noABNX qOw7Ui/A==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1pMwu0-005IoI-1G; Tue, 31 Jan 2023 20:06:48 +0000 Date: Tue, 31 Jan 2023 20:06:48 +0000 From: Al Viro To: linux-arch@vger.kernel.org Cc: linux-alpha@vger.kernel.org, linux-ia64@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Michal Simek , Dinh Nguyen , openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org, Linus Torvalds Subject: [PATCH 09/10] riscv: fix livelock in uaccess Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230131_120651_903376_27C8E9B6 X-CRM114-Status: GOOD ( 13.79 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org riscv equivalent of 26178ec11ef3 "x86: mm: consolidate VM_FAULT_RETRY handling" If e.g. get_user() triggers a page fault and a fatal signal is caught, we might end up with handle_mm_fault() returning VM_FAULT_RETRY and not doing anything to page tables. In such case we must *not* return to the faulting insn - that would repeat the entire thing without making any progress; what we need instead is to treat that as failed (user) memory access. Signed-off-by: Al Viro Tested-by: Björn Töpel Tested-by: Geert Uytterhoeven --- arch/riscv/mm/fault.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c index d86f7cebd4a7..c91d85349d39 100644 --- a/arch/riscv/mm/fault.c +++ b/arch/riscv/mm/fault.c @@ -324,8 +324,11 @@ asmlinkage void do_page_fault(struct pt_regs *regs) * signal first. We do not need to release the mmap_lock because it * would already be released in __lock_page_or_retry in mm/filemap.c. */ - if (fault_signal_pending(fault, regs)) + if (fault_signal_pending(fault, regs)) { + if (!user_mode(regs)) + no_context(regs, addr); return; + } /* The fault is fully completed (including releasing mmap lock) */ if (fault & VM_FAULT_COMPLETED) From patchwork Tue Jan 31 20:07:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13123371 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D48F9C38142 for ; Tue, 31 Jan 2023 20:07:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VfJ8j/NpqbQ0m3FNESr2oSVlhZ4YV0q37GGMDivrmWY=; b=VhpBLDGjV/AvrT vwIHWU4LdV8J4qlapcw0x1j1SJYeAwXkyJyujOOoP9Ir+L+jKSytJ77PBh4v/E75AEByHC+s5SXd0 MyN9CNdFc6936ihHj9JlLJllnD+hCy6xX0VI5jzf1kWaOF7FybWTz9dtl87hE0C7W2OY94kGo0gPR yA/rY/y4CbOIlbqVNtASX+vgAEHjoIhZOVKnL1J9DfZvyRqz3VyZry5+amMmnfMztms/UyMlsiroQ 3LYr6O+6aubcebWRxAo4UgToSwPBWMrqTr/uMQp/o/EbvpG0fSqOlSWecMRQENoxclINg0vF5BXsN lNkVhCsUqYkrE6rpoUGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwua-009DzA-8c; Tue, 31 Jan 2023 20:07:24 +0000 Received: from zeniv.linux.org.uk ([2a03:a000:7:0:5054:ff:fe1c:15ff]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMwuY-009DyK-A7 for linux-riscv@lists.infradead.org; Tue, 31 Jan 2023 20:07:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=fkGQb+Z+Q8nqxAsgBkwiDlyCIx3ldW4LiysiQRChEQY=; b=uiRdXlLmPVjFhiEbdNWx2iBg/L ukT6759SKWvD4VTcf7s8Zrnsy20tZQIyfGpDAYQMZK4Vr2bXIoZfz9SOM1xMKM3izRzmQrCiw1f59 7UEFhjpIZP09LO6b7yhwL8PNq1KyjxUHtjTU7yoIPqR36F37H94mx0pWJ3RipDcr8xYjM1AAKeQ3J xKdN74J8AHWk6MLBfur4EYMpaBLeXd7YgHATaE32CWS+oS9CqUV91B1jzUXKjV+MrSoHKbtmYhCoh 8etJOX4tJer3i70iBmbcFo15uIh3SC5WE7al3VG5ojYolEtBMrtuCEO4yPEAB5yxFlJ8pp4muojCB NT+qnH5Q==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1pMwuT-005Ioa-1X; Tue, 31 Jan 2023 20:07:17 +0000 Date: Tue, 31 Jan 2023 20:07:17 +0000 From: Al Viro To: linux-arch@vger.kernel.org Cc: linux-alpha@vger.kernel.org, linux-ia64@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Michal Simek , Dinh Nguyen , openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org, Linus Torvalds Subject: [PATCH 10/10] sparc: fix livelock in uaccess Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230131_120722_364676_600C0D05 X-CRM114-Status: GOOD ( 13.61 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org sparc equivalent of 26178ec11ef3 "x86: mm: consolidate VM_FAULT_RETRY handling" If e.g. get_user() triggers a page fault and a fatal signal is caught, we might end up with handle_mm_fault() returning VM_FAULT_RETRY and not doing anything to page tables. In such case we must *not* return to the faulting insn - that would repeat the entire thing without making any progress; what we need instead is to treat that as failed (user) memory access. Signed-off-by: Al Viro --- arch/sparc/mm/fault_32.c | 5 ++++- arch/sparc/mm/fault_64.c | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c index 91259f291c54..179295b14664 100644 --- a/arch/sparc/mm/fault_32.c +++ b/arch/sparc/mm/fault_32.c @@ -187,8 +187,11 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write, */ fault = handle_mm_fault(vma, address, flags, regs); - if (fault_signal_pending(fault, regs)) + if (fault_signal_pending(fault, regs)) { + if (!from_user) + goto no_context; return; + } /* The fault is fully completed (including releasing mmap lock) */ if (fault & VM_FAULT_COMPLETED) diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c index 4acc12eafbf5..d91305de694c 100644 --- a/arch/sparc/mm/fault_64.c +++ b/arch/sparc/mm/fault_64.c @@ -424,8 +424,13 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) fault = handle_mm_fault(vma, address, flags, regs); - if (fault_signal_pending(fault, regs)) + if (fault_signal_pending(fault, regs)) { + if (regs->tstate & TSTATE_PRIV) { + insn = get_fault_insn(regs, insn); + goto handle_kernel_fault; + } goto exit_exception; + } /* The fault is fully completed (including releasing mmap lock) */ if (fault & VM_FAULT_COMPLETED)