Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1138351rwd; Thu, 8 Jun 2023 12:47:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Dlq2yjYEZZ6yL5t5/nM4rhpggNUVWcHk2l5+J+2zB6lIBUAEpcnNY+SoHiPJb+deZqH4z X-Received: by 2002:a05:6a00:10cf:b0:63d:47ab:65ed with SMTP id d15-20020a056a0010cf00b0063d47ab65edmr6554328pfu.7.1686253662351; Thu, 08 Jun 2023 12:47:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686253662; cv=none; d=google.com; s=arc-20160816; b=qabbrA3e89KJ8Dkzpg2DZvCh8HmH3De7w35dddgQG5RMG5AIt+75uFX0DIU/9roQs2 NolsUdvt7OFaLpzvG5mIPy2OrZokeY49SQoAnxdNYQLe+f3Z7GbAdIT85we2eMpl+c/1 OqD2D1h5D69VOZCDjtylCjXTDum8oX/HQR2K2B/PTZFmcnCxoHlc4ySNjtVj7RZQUL+c IvFUrFPPEe3kDkMIhKfhbg3Z1jHWQjmxPqE7oT+dDsgBryiOFidVJmSwZFEoXpc5anfo 1Oqf7VeUgeX23i/OYRJiEEISlc89Oh575p/a/sekN8q4WHxLGNiHEf4wX0EXOYs8B4RH m85A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=5V1nU3Kqzs/xawWKyc6+rxjcg3uMlDunTMtenGe5HoU=; b=wkSC5+zhHHcmbwA6+UKlemItsEx621QsMp9fIUTABqvHOtPdG1mvYvQRqj9ge4XYmJ X9rA3SWKWbEBrqUc5SPtSFlqRLNtFmV3s47dtI9tuf2BrFUCc2RBazVyxK5G+wx/n6Ny xGb1baUOpjizXewKAaNKdaKs1WxX92rinoUBgdfJzkE6E4a81OspsvJdFEHh96dckwAW vpwQp3Zc9Uzo0YrTn59wf7o/bM1A6tVKrDmgytKG1i8+VXLRIzVAhL0Hrjx6NCPAQNaT cqkYJi5hL9KxcuuzaEyGhMJ0MyE9UlJgGU/3FgLqgwa/U2xg5qhLzpQTtz7FvRD4mXXv XDtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=24t2BtFN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 6-20020a621906000000b0064583a79521si1206934pfz.283.2023.06.08.12.47.27; Thu, 08 Jun 2023 12:47:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=24t2BtFN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232119AbjFHTcq (ORCPT + 99 others); Thu, 8 Jun 2023 15:32:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233539AbjFHTco (ORCPT ); Thu, 8 Jun 2023 15:32:44 -0400 Received: from mail-yb1-xb2d.google.com (mail-yb1-xb2d.google.com [IPv6:2607:f8b0:4864:20::b2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C17542119 for ; Thu, 8 Jun 2023 12:32:41 -0700 (PDT) Received: by mail-yb1-xb2d.google.com with SMTP id 3f1490d57ef6-bacfb7acdb7so1080729276.0 for ; Thu, 08 Jun 2023 12:32:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252761; x=1688844761; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=5V1nU3Kqzs/xawWKyc6+rxjcg3uMlDunTMtenGe5HoU=; b=24t2BtFN5HXeEnWp4wmjqaz3ba7RZTv3BWN8E2lDsHPicXiEJRz9TlH2WLVzGd8CdE of2yNqyqdnSUhfcGIlOsfvovWhpuG53taZz/x9DR/Th5PIOmYH7IKtDML+zGnAiDR7yW CrmldFZSb2omivw75gysl+pOyy7IV7uE8SzN+doaYOlbMw3OdLZlcS0TMi0ZgvmIeRDQ MJq/tuPeT8xPnNmBXjEKmMP3qPQGwnStEjRQklqNa0dtkxFHtF5PvuvrSEAvR9DPSdcW McnyT5sGz87Djsd0XbZMK04rqnZG7iDmeQmmJXSZxSQJU2i6hoMEpfITW8x1lOY4n4VU tBMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252761; x=1688844761; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5V1nU3Kqzs/xawWKyc6+rxjcg3uMlDunTMtenGe5HoU=; b=URbUJKr4cMZjMx4TR2n9tL/v81bSHKXUtg+/ki0rThbhK/zmx6uri/LkaPD6vBmMyk xl1po7uo1nd3cwQEXVCFHZGNEat93zA1pqFcPdjHxIefzkWgX2CG5ovf+L3s+6/X0BKY wShSUBw/OmH/CwhoQ951VdHqiJyFP7wXGm7XCfrU6DfOwjsE6AFl3isndtJts9WkXidh 4ZluH+vHwizsrpnNdYU4pL7/KqF02sdbLVG8tqJc/wrKT9/G20Ob0DtJ41Vqm3T5gUvY EzUrDe4RL/rfzQx/6Xicbt/CvK/EpEftHQBcRTaszDwjJRS4UR2McEfQPn4XqNJtGShD itVA== X-Gm-Message-State: AC+VfDwyVpXPDK3q65zt0hlfa1ysr5FoXC11o+X19DOTntW3zaLrx/TM TE9ZGYR8VHt8OT6jwVQdRs/vpA== X-Received: by 2002:a25:f40b:0:b0:ba8:54c4:3136 with SMTP id q11-20020a25f40b000000b00ba854c43136mr602795ybd.52.1686252760634; Thu, 08 Jun 2023 12:32:40 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id k7-20020a258c07000000b00bb0ae4221b8sm428913ybl.43.2023.06.08.12.32.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:32:40 -0700 (PDT) Date: Thu, 8 Jun 2023 12:32:36 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Peter Zijlstra , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 19/23] sparc: allow pte_offset_map() to fail In-Reply-To: Message-ID: <22165adb-581c-9ce1-8aa6-a3385cd39055@google.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In rare transient cases, not yet made possible, pte_offset_map() and pte_offset_map_lock() may not find a page table: handle appropriately. Signed-off-by: Hugh Dickins --- arch/sparc/kernel/signal32.c | 2 ++ arch/sparc/mm/fault_64.c | 3 +++ arch/sparc/mm/tlb.c | 2 ++ 3 files changed, 7 insertions(+) diff --git a/arch/sparc/kernel/signal32.c b/arch/sparc/kernel/signal32.c index dad38960d1a8..ca450c7bc53f 100644 --- a/arch/sparc/kernel/signal32.c +++ b/arch/sparc/kernel/signal32.c @@ -328,6 +328,8 @@ static void flush_signal_insns(unsigned long address) goto out_irqs_on; ptep = pte_offset_map(pmdp, address); + if (!ptep) + goto out_irqs_on; pte = *ptep; if (!pte_present(pte)) goto out_unmap; diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c index d91305de694c..d8a407fbe350 100644 --- a/arch/sparc/mm/fault_64.c +++ b/arch/sparc/mm/fault_64.c @@ -99,6 +99,7 @@ static unsigned int get_user_insn(unsigned long tpc) local_irq_disable(); pmdp = pmd_offset(pudp, tpc); +again: if (pmd_none(*pmdp) || unlikely(pmd_bad(*pmdp))) goto out_irq_enable; @@ -115,6 +116,8 @@ static unsigned int get_user_insn(unsigned long tpc) #endif { ptep = pte_offset_map(pmdp, tpc); + if (!ptep) + goto again; pte = *ptep; if (pte_present(pte)) { pa = (pte_pfn(pte) << PAGE_SHIFT); diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c index 9a725547578e..7ecf8556947a 100644 --- a/arch/sparc/mm/tlb.c +++ b/arch/sparc/mm/tlb.c @@ -149,6 +149,8 @@ static void tlb_batch_pmd_scan(struct mm_struct *mm, unsigned long vaddr, pte_t *pte; pte = pte_offset_map(&pmd, vaddr); + if (!pte) + return; end = vaddr + HPAGE_SIZE; while (vaddr < end) { if (pte_val(*pte) & _PAGE_VALID) { -- 2.35.3