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: 13272822 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 03581C7EE29 for ; Thu, 8 Jun 2023 19:35:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A11D8E0005; Thu, 8 Jun 2023 15:35:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 92A878E0001; Thu, 8 Jun 2023 15:35:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A5AC8E0005; Thu, 8 Jun 2023 15:35:17 -0400 (EDT) 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 64F4A8E0001 for ; Thu, 8 Jun 2023 15:35:17 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 342921C7A1F for ; Thu, 8 Jun 2023 19:35:17 +0000 (UTC) X-FDA: 80880584274.03.DF6125D Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) by imf09.hostedemail.com (Postfix) with ESMTP id 27098140011 for ; Thu, 8 Jun 2023 19:35:14 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=IGMMSO5m; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf09.hostedemail.com: domain of hughd@google.com designates 209.85.167.175 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686252915; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=kr0PEHV5OnE+EEUWt8DnaCebmsfgt0XKMU/SCuO3z3o=; b=VDGVwRPswRdgA2P1vgl7cbUEtRXfeNo3RcPbiQIXyW9KqP40mE3Ln3o6TWzXLRe95rNbpW 1LPFivViPQu4OAPJT8zQU3WUxNfDgrf+QEdyCQmpgFDT7EIn+cjmV+RbqxgPfufxyrCAaz Q65mIc0yk2fLvVZXcKYnORuA7e2NY7c= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=IGMMSO5m; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf09.hostedemail.com: domain of hughd@google.com designates 209.85.167.175 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686252915; a=rsa-sha256; cv=none; b=IaymTKboqb3ubE2FPbDwE2OSrcZbjCreEVtTWdYRq+KzldjkWwhkJr4KyyjpuSEGQUbsFX LdN47Z8fLDzhLWjY55un33VsI5paN915HHQG4oYm1fgPpfW8aS5ioB3Esrhhott5PIHRhp KmEIlU8+34RnAyxOL1cUL2mDPVon1Tc= Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-392116b8f31so42196b6e.2 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=jNrHYvqR8I1uJTS2HtZyuirOVuSa5QqSA8EmnSSaX3YDXiyxiczQwanNOCGo+c5hbe 1l3kAM5Soi9ePPg+bi+FsTOIC835HuLa2aJsngOjS02DKQOKE7GNVikXt69UEVPdjrKt S+Qslk52TLwDWiHRDcWKN5o2pQf09gPhhC+JdptFdnVBYIPfYgoQW8S2jxSqgFqECw+3 +kbguGUWrqteooqGpzGbElw0NUZwIswqPxNV8XjEZ045flCvVp40IEJkMCQmQNQIjqPq /eYsqVUPtrPD3UvQ7SCipIldezpELeJkjKO4ycoCs9wdt4tZHj8i27m7LI6Mp/psw5kZ KlUQ== X-Gm-Message-State: AC+VfDy12DfawMcKIksW9neuesH6bXZ8uScnw2axgCZAb9Itov7loOJU mou9Qg4dg7wZyMS/Xpfp+D6QCg== X-Google-Smtp-Source: ACHHUZ7gdIjuH/6E76ySqRN8WufhpANLQ+j2jIa26lg+ERfDlrQvd+huECUh9/LluoEXiOqTeuRs9w== 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-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 27098140011 X-Stat-Signature: 7zu47zkaexc65y6os8gndqnqobk69bzz X-Rspam-User: X-HE-Tag: 1686252914-93952 X-HE-Meta: U2FsdGVkX1/TrZg17wGb3u8HRosv5cAMR6EXjZ5rfJjnYepVmir4JoxsNlquO5ISnhwBTwdZoisUhePuhjUM0QAdkUwdK2GQi++f/7PFm+9UCayrMATSDU2wE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1HVOP3P433V7vuAvjP7tadepZB2qD6fI6T+/o0wyzgbz23UFQb7svwBpZjCMolPernR5MCG6h3jPbz9hMNNzD5N9Djs5ic8buFFEOO1IitI4Rw3Q10PxdMRG0Sph496aQ1Pbc7STG+kXX6JuZZWqW4XSXYRtyrGeKekEyAD3JNwGdKuCGpGIJO+Fhbvmr/gw2EI8uafaEc9TUbJlwYEL++mWJseQSypQnOL/HYV4gIrt60= 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: 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);