From patchwork Wed Jul 11 11:29:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10519489 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 151F3603D7 for ; Wed, 11 Jul 2018 11:31:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 182D428813 for ; Wed, 11 Jul 2018 11:31:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C16B28844; Wed, 11 Jul 2018 11:31:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97A1128813 for ; Wed, 11 Jul 2018 11:31:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84E7D6B0287; Wed, 11 Jul 2018 07:30:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7D2846B0288; Wed, 11 Jul 2018 07:30:17 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 62A9A6B0289; Wed, 11 Jul 2018 07:30:17 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id F15466B0287 for ; Wed, 11 Jul 2018 07:30:16 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id x21-v6so5799907eds.2 for ; Wed, 11 Jul 2018 04:30:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=KIBsnwEP+43vhTh1Iluta+0HkmzOIXd2V1RUuYnU6lM=; b=BWR9FhljQTVwR4U/S3vQtYQZq91ibF6W2fFHZRcPCT9IO8EmU17hu4ZIYG/oYi/hPU 8y7m8SapOZ8jCb0J/UK/VSxwsxOU8arE7Wf2HRuJLwxb6FCy/4qdoSxbZH9sPia7Qvrn cWiMzUcizx7bhftMrGic8o8+/2yP9JhCMVusTWqR0kPSbCCLJNsvNTZ6jTI6c5BluWtJ Gu6tnYKj8ziFZBLISeAC/3rsHOlhEYDryBMxJN7GWfClkt4YacU4x/KbXtRD5sMrZKUZ ZOZj6BRJkRQ/AFPfgMnar+rxjNvMEbujA7noNqOxSuyzFi8G4wU5gvYMJGwae0FIUDqQ Sr7A== X-Gm-Message-State: APt69E0T6d1P9N3MiUZFP+bg2ECWI0lzauZ79VdoyPYQ0tlnyJ86Hfdy H3mYUeLfeTHVWLvGPqW05S+KDbc//UAaL8gijriuVmdgot64sgxeac72xw9m/rODMFongn0ZefN 7a4D9X7TeMcOwQJWV6wwm4+5A3DQOW3Rax9a/TbYjDaeWa+omPSJaDphCsOmhwrS4aw== X-Received: by 2002:a50:8b66:: with SMTP id l93-v6mr30664511edl.44.1531308616553; Wed, 11 Jul 2018 04:30:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdUCME5Z92kpi1gBEECnSwHagRyl6Pl0fjT5+mkgQdFys20NxeggzgvX00c4BjEbNROV1+f X-Received: by 2002:a50:8b66:: with SMTP id l93-v6mr30664475edl.44.1531308615864; Wed, 11 Jul 2018 04:30:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531308615; cv=none; d=google.com; s=arc-20160816; b=Fd4/9POI6eEanjpfcvP2RbxCGqZFReXtPoVcxLJnFovnhUox8a8KlFptNSlgWaAZj+ PRnOIrQUFU7XMVvWATYtgf/qwa8nq/+xUky1dbQRJ1k+IaHIYW19yWnqLSTTCrLgamVf H6e5o4PYF1Rv3BlYFRrg/nkx4mUnx/LTYxmGOZVqRsNVsHQCeqP51dFa96lGtyTIaFM1 5UaRjAkChI/HJCbI+mNJa6T1YowLEPsECQ2RVpiDyxcEFE3coyEzmU1lfqU9Wm6J5kVw rSrkhCo2RrSA/MhK9dCV42vreMYiGPgJ+1eDSEo1fSYXwkySUBwn0cLD9EulQUNCJJgE SvhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=KIBsnwEP+43vhTh1Iluta+0HkmzOIXd2V1RUuYnU6lM=; b=hb0FPy24JB4ISliCK6t+c/VBwa9ZtJfr0711NK/8pxE9A/8QGVnTh60lo00DUyuCwF Fn5QI1xbroI8xPvyJCdzXc0Nkf9ZO99K7wIp5lx42/LbKewrqeltfm3Hkd5jbsg51z1D T8yEMh4SC4h42c/aaDEsdv0UeUtpGQQy51e9HvxHYJQYfCT8W2/kssSVrFDz+l5Kq+ap 8HJFu4rROE5fBO3u6ENCd/0rvuWaTVNlwdsVsYRICqR5/TD14h75rd3tSL9tGcz6bian p6gsXgDEbHr8FLvOHTXi5rftVb3vV2PlfwpjtRtU9b33/SniKEGTZhTZi+LzhGf4hSaP /OIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=YJPK2dVi; spf=pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: from theia.8bytes.org (8bytes.org. [2a01:238:4383:600:38bc:a715:4b6d:a889]) by mx.google.com with ESMTPS id e40-v6si603606ede.100.2018.07.11.04.30.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jul 2018 04:30:15 -0700 (PDT) Received-SPF: pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 as permitted sender) client-ip=2a01:238:4383:600:38bc:a715:4b6d:a889; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=YJPK2dVi; spf=pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: by theia.8bytes.org (Postfix, from userid 1000) id CFA61AF1; Wed, 11 Jul 2018 13:30:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1531308605; bh=ZUviePOIgsE5gr4utevp7AAlceBk2UMlvJXiUAzZDAo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YJPK2dVikT1QTf11eAOH6cpGO/plvjWVTnhAhHQRXXRmN8fic3Xm3fxwOSuiCTKUV kIrW0RN8Uktoee7yFRs6qi8LRYOi3Ropmi4Nc45NzBaYPugye9wv6qk7vZ8mhYW2qC Uw0Zmm3G58VBApBlM6yTZduxMKepwhNBj5aMkaT4+2z/Q8c07V3SHaQV8Ip4oOQABd N+vlAksWg/ok5Fnw/rkAUgMkKzMzAsXp3+puj8KkJ4Fv0RweVvSxJKSO9qxrrIrXBZ jDa1tyZQTdJMdu1VfduC83myP5G1/ys0sl4A0ZSqEZ+NDT3Zesfv1XmGe0B9MFoqj1 h7FTpxh3pP4pQ== From: Joerg Roedel To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Andy Lutomirski , Dave Hansen , Josh Poimboeuf , Juergen Gross , Peter Zijlstra , Borislav Petkov , Jiri Kosina , Boris Ostrovsky , Brian Gerst , David Laight , Denys Vlasenko , Eduardo Valentin , Greg KH , Will Deacon , aliguori@amazon.com, daniel.gruss@iaik.tugraz.at, hughd@google.com, keescook@google.com, Andrea Arcangeli , Waiman Long , Pavel Machek , "David H . Gutteridge" , jroedel@suse.de, joro@8bytes.org Subject: [PATCH 24/39] x86/mm/pti: Add an overflow check to pti_clone_pmds() Date: Wed, 11 Jul 2018 13:29:31 +0200 Message-Id: <1531308586-29340-25-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531308586-29340-1-git-send-email-joro@8bytes.org> References: <1531308586-29340-1-git-send-email-joro@8bytes.org> 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: X-Virus-Scanned: ClamAV using ClamSMTP From: Joerg Roedel The addr counter will overflow if we clone the last PMD of the address space, resulting in an endless loop. Check for that and bail out of the loop when it happens. Signed-off-by: Joerg Roedel --- arch/x86/mm/pti.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c index f512222..dc02fd4 100644 --- a/arch/x86/mm/pti.c +++ b/arch/x86/mm/pti.c @@ -297,6 +297,10 @@ pti_clone_pmds(unsigned long start, unsigned long end, pmdval_t clear) p4d_t *p4d; pud_t *pud; + /* Overflow check */ + if (addr < start) + break; + pgd = pgd_offset_k(addr); if (WARN_ON(pgd_none(*pgd))) return;