From patchwork Wed May 10 05:08:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13236422 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 B1A71C77B7D for ; Wed, 10 May 2023 05:08:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4553E6B0071; Wed, 10 May 2023 01:08:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 42CE26B0072; Wed, 10 May 2023 01:08:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2CE666B0074; Wed, 10 May 2023 01:08:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 1E61F6B0071 for ; Wed, 10 May 2023 01:08:44 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E620AC0440 for ; Wed, 10 May 2023 05:08:43 +0000 (UTC) X-FDA: 80773165326.06.604DFFC Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) by imf22.hostedemail.com (Postfix) with ESMTP id 1DEEFC0003 for ; Wed, 10 May 2023 05:08:41 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=xhQbPYpk; spf=pass (imf22.hostedemail.com: domain of hughd@google.com designates 209.85.219.182 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683695322; a=rsa-sha256; cv=none; b=8mwtA6qlgw95aOoDV0+/Dh9x8TSBPOkBryVu9/LrLYB9ZebMeN327/COwqoGc1Msv5S6RH H8quLAzODQYXRrSa46AbEIBUe65lauSZftoPhsixLU5zMKlRdc/zIN/GaFIvVf2oCJmHbF rocQ4kcvkbAS8DvNdgTwO3Lwv241kLg= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=xhQbPYpk; spf=pass (imf22.hostedemail.com: domain of hughd@google.com designates 209.85.219.182 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1683695322; 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=OTtpK1Un44XLqqGJYzxkLaX59Gadt3u8x45iMKydYoY=; b=FYYzrthB4xHTWIfGRML1YM/RYGGVfMpcwMADtD7/Ec3soG+iaSzM8c1V9xE1LmoScWHl+R DKdJdcxaskHOa8CA0MoysbdFCKZPeMd5e/TP2I4+8+lwECkdMYsTa/NtSYHvcHuvUnytwc EyusMuVXzihfrQg2tb11OSUrAjU+mgY= Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-b9d8730fe5aso8894671276.1 for ; Tue, 09 May 2023 22:08:41 -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=FvanmQFRF5aYbSQKDkmrFNxV8cfi/CT87OMf2SgY9AXrobeTPAZeqyh8wP80NhB4lO AUYXeE2wAzWOxGUQGyMCGI7Y3FJlmCFwwGfor4/nJXddluCU3ch5Ip+3tccHgs44dsNB TPzQgGSs61N66C1s/Bqdo+nG22oPtwBlyiI0x6HE6WGJFG3VHh123C4DI5+9o0uW8q3e 6kNB9l8dwJO0b9u3fswdlxn2csOqlyKfVgRN4dUVuYe52vWW/7hJC/dUDiDLYSi2dMi4 LdtPu/Ch2Zqt/qesUxoHxTAJLERlqu1BFdHqGO7RMPsocmmkYFJrOk6hbOW8nazZa/o4 i0Og== X-Gm-Message-State: AC+VfDz85w0ZCvto3rZljV8a9gQ9d5KC//04zfI6dOQ6k2c8JDZG8x59 L8iLNcbWHpRYniOsKPQbtIZGKQ== X-Google-Smtp-Source: ACHHUZ4Nr7JCTjKD9JrQLs38TYvzUeemCSYHOU0HaXL9Z0TKs+cs2kkX5Dm1CGmBCetCdz6AhjKuwg== 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 X-Rspam-User: X-Stat-Signature: rcdy16iwwkmqep1fxrnuygfafsya9o3e X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 1DEEFC0003 X-HE-Tag: 1683695321-209004 X-HE-Meta: U2FsdGVkX180T6cPoTtxrZuk4BhdBoqT+e5d5tKrRpNkLuqwbFK/K7RMcGWss0yhitsHY+31Sggs58TAR7Mk76fcI5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gsriEhyaq5MaTKL2umT6bZd0oJxRGZhzwocwOwC6B3ztxDfzMtmOGF7HnThYsE4kciHjL+VltKlUzP4zcuBnuoGsw9Xz/jvTOD1yJi+TM5xUpIJr+tyxZCL4DGhGARu1Acc9SrUefT2C07SsPjw0XenBHqYkK+2K48Pf4boaC4sPqUefXwsvOo7C2LwBUKXCh4ApFy4SkowLYWeTuoz5elyIT+xp50oubrz3oRlsQvts8kJ8B6E+NzHjljA5rbEmSv1rt15SfuPkuohF3Dp9xp0= 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..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);