Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6790984rwr; Tue, 9 May 2023 22:25:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ugQAB4ukq2u/dCqvM4PTmo/yoVGiATEZ4WaND6MK8qlAidRe/yNAM1OeOzpYYmI4XGOEF X-Received: by 2002:a05:6a21:6d8e:b0:100:916:d111 with SMTP id wl14-20020a056a216d8e00b001000916d111mr14715043pzb.24.1683696354015; Tue, 09 May 2023 22:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683696353; cv=none; d=google.com; s=arc-20160816; b=KjY/jrSwxbF2TRhRM8rMIFwyyXyJc4fkEZ9XQNA6sztXIhFMmB/T9U/bsUZhE18qu9 9qQFXuhU2pDXDMVOO47KHGZ8SzIhVWgSJo+caGmb2pXeWXb9h/W32qchRYWO8eN4+qhJ 4n3wyEX1xT3fXyinbGIsdBFq+S9gCZC7SXQ17j2ViVTONH+jWsp6ZDIjyuQtF7COI9TL OvtBGCfY7MSgjVd9jNMBJ+J1B7KlgeviDyd7ykj71prFaGsxDnYpwNJqVo+REg+N395d KJYngqzyGfXppeJsLObMa6vY91JSAvjlkRQv+3pDmwRU/ByN03KfjPG6tBK2wG/8rU51 nPTg== 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=OTtpK1Un44XLqqGJYzxkLaX59Gadt3u8x45iMKydYoY=; b=OwKgtfPqzzpYDuT22880lFVuFuLYHehNRIlk/RqAja+SznbJc3O4kZA/mNqxwMTYls 1BCjb73p/p7+PpScZyhB+znqg4qd2xMdRHZfn69LzFp5bEMIKUIG7CR+mbV4Gz95K090 5BAiFLceZ7M0r0Inu8S6qLosrB0E98+Cgv4AZ26LjPITnpi4yjz31TZ88kOqsBwAOk26 qBjeygdxomlaSHvxswsK1JtXIrE7bw5V+xDOROUYwFfW93rqv1zCc95FH/VBpSDBCkvo s3HGqCSd2ywfeDvZiuu4CTxTdXaTxuY8TexE6TnJou3IoEWbhNKgyoDHFf/slehDoZBv MDGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=xhQbPYpk; 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 c20-20020a6566d4000000b005303a7ca052si3272485pgw.491.2023.05.09.22.25.40; Tue, 09 May 2023 22:25:53 -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=xhQbPYpk; 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 S235927AbjEJFIt (ORCPT + 99 others); Wed, 10 May 2023 01:08:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235931AbjEJFIp (ORCPT ); Wed, 10 May 2023 01:08:45 -0400 Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C1D0525A for ; Tue, 9 May 2023 22:08:42 -0700 (PDT) Received: by mail-yb1-xb31.google.com with SMTP id 3f1490d57ef6-b9e66ce80acso8883689276.3 for ; Tue, 09 May 2023 22:08:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683695321; x=1686287321; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=OTtpK1Un44XLqqGJYzxkLaX59Gadt3u8x45iMKydYoY=; b=xhQbPYpkUzDX8XU9iKlY3Y4428jn5y6GTm9xV45/y6OmNC04/3wNqkNgSXK3AJIxCv nf/3Kcyf7jXHraRNp8V/ThTGssm80Jrj1vFIVRl/eHnHIKGHX0llNwJFmswFPBKeszPS 4ERvsVZvFaG63Gj8ZvkLnyoFsbatfd0tOGpnHcmb7QKy8F/PI1niiK9/bIJQ3clEICAC OKKiuKdx+Nga+KesCEIBcMETZuPReDAYyeYXYun87fEO018ylr/CbkSFeoHJtNA1RKEB SehH79xiSdMYH54KoBHTNvBbumLZBWgNKrjc9IJ4jvy2Xlbglq/VfxJ2yKtHyPoLu9Db naUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683695321; x=1686287321; 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=OTtpK1Un44XLqqGJYzxkLaX59Gadt3u8x45iMKydYoY=; b=h0sQRQPAg9yBfSKRbdF7gT8nN4tjYyCDrDvLyo/4TZiIHkBkODXSV1GsIMHvFNtSey OICQN7C3ww/AX/ECvtfCR0fwyEwiUmpqyncBSLvc2jBKYgL0Hv0L60jH0uxEO3A3v8K4 yQveLCmW4wTn9rmPuBbpIO4/KFVFtwXnVxRPk2Efay2BcCx8t+GBznuKdbKj2SL9JZwP X1Lg8joWNPM2JVffnkgXAeQxX7VjwU03m+dxuniw9WXAxiNV/uoxu6BSatRlfoUjOfkS Yuhx5X6c2eiI5b5tqb3NGpD7cZpBK8gYAVQhydrPqEzP6fSy67eJiT/0+vQSNRwMPbmB v9vw== X-Gm-Message-State: AC+VfDyf75FlzpkAcWHBn+JDixMz5bfMxARMDyduQh4e0DS8e6n+Wmb/ EONC6oVOnWT6EuQ5Ywq6c5Z70Q== X-Received: by 2002:a25:b228:0:b0:b92:2e22:aba5 with SMTP id i40-20020a25b228000000b00b922e22aba5mr17628224ybj.11.1683695321141; Tue, 09 May 2023 22:08:41 -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 7-20020a250a07000000b00b9dcd17cc2dsm3512897ybk.46.2023.05.09.22.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 22:08:40 -0700 (PDT) Date: Tue, 9 May 2023 22:08:37 -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 , 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 , 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 21/23] x86: Allow get_locked_pte() to fail In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> 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/x86/kernel/ldt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c index 525876e7b9f4..eb844549cd83 100644 --- a/arch/x86/kernel/ldt.c +++ b/arch/x86/kernel/ldt.c @@ -367,8 +367,10 @@ static void unmap_ldt_struct(struct mm_struct *mm, struct ldt_struct *ldt) va = (unsigned long)ldt_slot_va(ldt->slot) + offset; ptep = get_locked_pte(mm, va, &ptl); - pte_clear(mm, va, ptep); - pte_unmap_unlock(ptep, ptl); + if (ptep) { + pte_clear(mm, va, ptep); + pte_unmap_unlock(ptep, ptl); + } } va = (unsigned long)ldt_slot_va(ldt->slot); -- 2.35.3