From patchwork Thu Jun 8 19:35:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 105121 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp518895vqr; Thu, 8 Jun 2023 13:16:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Mq25GcdxD2+XZE1eJBd2QvCf3R4788ZyFh7FS+mHkJVzdDdpyOrARc2FvNRX63v7IVBqb X-Received: by 2002:a05:6358:e81a:b0:129:c25e:1caf with SMTP id gi26-20020a056358e81a00b00129c25e1cafmr4971098rwb.3.1686255413997; Thu, 08 Jun 2023 13:16:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686255413; cv=none; d=google.com; s=arc-20160816; b=QOXL0/25Y/OMV3D+024Z6cYlPOMipI9XqRDRnABGR/svtvuTRrPNdwA2p3Hpsbyys8 tVop4MAN5W1uvIs7NItMG4FsZYwOk8o+t+TjnV6MshUZJLxqOhlO5T/21KmOBho+c2Gx NDezcbftTv2vRVSWCeWJ84X8VoyJMdzxPQRlp0Lxf7gr+nzj5sAfttPuzQ28gbwaP2tM xaTdqk8zaLigg9MdaOnt0f20/FMjWr1AgrIYEPcmBtAxDuFpkletcpMRPmba6GuugGPL HNwZAVlRX3aDc+AJwq8g8AYxvyFQCSz8/pTAVT+YcacofcOEcRbddGM4+xvIRNMpQGVa ni0A== 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=kr0PEHV5OnE+EEUWt8DnaCebmsfgt0XKMU/SCuO3z3o=; b=WgFTmCpuXCgYCcSIhNrbI9y+MM4MhATuRiXIdowpUN314txGM685SEnDAgW5kT/v8+ Zn5x1xY266LroEZ5PVwwJweHCIr5MG/1LL5U7cD0vsE+AmgVtYCBGW9eJvZwE4SJWnej m7zrimFHwFo8n70qcaERGjWFkO3pFdPc1DXh2TJ1oixwXm8g81Emg21ALdIxqE7H37u4 3Za1q/A118+yGEZ+Hhwqz6aLRv+AfIeyYZQncs5FzR8uSzDBAxnxFG4DwJUnzTZbGPaz cPR+1FzGjWVLexuHk3FYCD5VajESGIwA8v7iUx8PPdtToty0oA76CwZfGMshTEKR2M0C kpNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=IGMMSO5m; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z12-20020a63b90c000000b0053ff2ca1b24si1344837pge.843.2023.06.08.13.16.39; Thu, 08 Jun 2023 13:16: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=IGMMSO5m; 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 S236605AbjFHTfX (ORCPT + 99 others); Thu, 8 Jun 2023 15:35:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236332AbjFHTfU (ORCPT ); Thu, 8 Jun 2023 15:35:20 -0400 Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E90172D51 for ; Thu, 8 Jun 2023 12:35:14 -0700 (PDT) Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-390723f815fso41003b6e.3 for ; Thu, 08 Jun 2023 12:35:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686252914; x=1688844914; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=kr0PEHV5OnE+EEUWt8DnaCebmsfgt0XKMU/SCuO3z3o=; b=IGMMSO5mseD7tMe+rRtOIzITR5LLF6gSj6DDkJB5GA4sfv+l0xQcNm+4SRn9cSTA+K bzPDoNl4QAtanNBNtw4EO4Jh9TOBqBvtAeMzqVR0kpqSUA/L/bvTchhidEBh3MP4oHsE 7zzo3x/NewiOg3sZOatxsUi0TcVM8A38QB4oSQfrmI5m9Mp6eOh1v9F27aPIV0BM3Y9m jqm85o0LQ0rhNRucFZ0i7HQcaeWJpsz64iPtGPt0XsZOnDRNlY3xajIra5PnrJSK9OoE jKjJyQ6PxwcJN3nFoobZxXBieXcQTT3OQ2VZ4F5eEeV/iMRllpjt6DpnkAeaktGC324Y dn+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686252914; x=1688844914; 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=kr0PEHV5OnE+EEUWt8DnaCebmsfgt0XKMU/SCuO3z3o=; b=N3SH54DnlCPlG7hklAlvtv91NHn7yWujypfq8D/o8rUYseOHoUG6vH3M9o6nErTWJ0 NzDYglXGsZ+fto08ddKlH0oNkqmPOo5wwcjdHFWXhQSF44tfmxGnw/AG7zSxFNDmP4Xm KCWyumnkwbaZzyU4+ivRWdR33cmHDHSFMJIyox5mx8kjlP0vuIe08/kKGH/Xqd1d5dgj 7EwppJ06U8Q53UlS8gpF5AIQ3TkQnucM/9TEjFmaE7nFHaewxRJibVGR1npCIn+1SMBp vo743TuMYHZs9UIclG/U3/B6KiXRCqgZktRdW8xRKfPtjXu/AC5kzz+MfLf04xI1Eiz8 goxA== X-Gm-Message-State: AC+VfDxIWCL2LsC/XcwhEViIY54gKjEuj1KQ8C1wyyfgYM43c9qJKhBb ppg3vBXx6iwlF4j2Zu5jEN9UZQ== X-Received: by 2002:a05:6808:cd:b0:39a:519c:2a6a with SMTP id t13-20020a05680800cd00b0039a519c2a6amr6836715oic.43.1686252914190; Thu, 08 Jun 2023 12:35:14 -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 g137-20020a0ddd8f000000b0055d8768408dsm108055ywe.105.2023.06.08.12.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:35:13 -0700 (PDT) Date: Thu, 8 Jun 2023 12:35:09 -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 21/23] x86: Allow get_locked_pte() to fail In-Reply-To: Message-ID: References: MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768166956932786850?= X-GMAIL-MSGID: =?utf-8?q?1768166956932786850?= 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..adc67f98819a 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 (!WARN_ON_ONCE(!ptep)) { + pte_clear(mm, va, ptep); + pte_unmap_unlock(ptep, ptl); + } } va = (unsigned long)ldt_slot_va(ldt->slot);