From patchwork Wed Jul 18 09:41:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10531867 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 04AB8600F4 for ; Wed, 18 Jul 2018 09:42:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8EEC28FBC for ; Wed, 18 Jul 2018 09:42:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC7D928FCD; Wed, 18 Jul 2018 09:42:36 +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 8364B28FBC for ; Wed, 18 Jul 2018 09:42:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F19A86B0285; Wed, 18 Jul 2018 05:41:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id ECAC66B0286; Wed, 18 Jul 2018 05:41:35 -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 DB85D6B0287; Wed, 18 Jul 2018 05:41:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 6350A6B0286 for ; Wed, 18 Jul 2018 05:41:35 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id d30-v6so1705376edd.0 for ; Wed, 18 Jul 2018 02:41:35 -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=NXRyhzo9n5/S+wyo6j+yh5FQVAgNJY7oezzxzVnpc+oSB9exe0Sj8Iou8QRf2ZybCN 1/Ut2fzhr3myVULQlxEH+ejeuUf9uLDi6OeDuot2oraPRHq8u5OcvYgEE/CPo/FB1LcH tONj3Z/zZP2rApG9sWUAkkI3sMUCjL4YeGEdYsungdN5PK9VlqgNzu6ZEODoJFxDaTKn re+GVmjHfdbwOn/q4O413rCOLN8I8hW80rDAQFe+Yy+9X5MMNv2UlbFb881r9+EYR5Qu GdK4JU8ieJe+t35euPV4ItpXS8XY6nAgYV4CRuKeeROtPzEUmPvxfukIbr3sZ1/iqxcC cA7g== X-Gm-Message-State: AOUpUlFYdyNri4N4YX33AFPFVhqk7GrvnQK/KvDA4dpXav6Cn6TS6bLB bgD+eoLSdS9pZy4PdBg9mhRMn7zRdDEwK9d/NtlwnHX1+tG4dDkvUBXYbRw4jRHS76K9LwsjVse l/AWAypZjjRwBrDBljCSwqxjgNA17AHW166gmSHmfsc1e5UvxSBOOgT23MpfLZ1j8Tw== X-Received: by 2002:a50:e885:: with SMTP id f5-v6mr6359324edn.39.1531906894983; Wed, 18 Jul 2018 02:41:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfMyydFHLSxscNv5yRN8Lakn82CbGSkkY8QT7rhLhyg10wVpBJhPGXCkAjcR6xkCnTs7sSv X-Received: by 2002:a50:e885:: with SMTP id f5-v6mr6359290edn.39.1531906894372; Wed, 18 Jul 2018 02:41:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531906894; cv=none; d=google.com; s=arc-20160816; b=tWLrOQxswBk6jHiqGQOhLLW134JnsUVzYnjGNWKK7dyciBtOeFG/h1hyahYnka1DWj A9uthNKk0XwXcksfEeHO5m7x4vjIKJA3Ubq56otI/aZatZFX7bpGymUAHGwfu54/JWOJ 2hFAvEins9FAD3L0yChKOiZe3J/7mmyUl6+QCdsxX9HT3ZCKqNpn/h1mF1m3Tm7ItcCw rJnaveeHK/3Zd+YH4XKmZa8n4OT5QdL7gwf1P2GC28xtDhTf+lAIz6GhE8JfeoyJVhna DS/yYdqvnBy9D1djGyDAi9UgwMJhF/pL3xD33WzWhKZsMgya49hlIS2Fs7pyzaxfrH8J 9aFA== 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=q8c6ViU4F7VfbmOR3hYordfSIulfeeX+KSK/+iz5nbGFz/p2DxMVSAHu1K9hEXBXtC 3m6T/Z7qHSFGl48SJ03GkwbtDW44jyF7s9wDpiC+8KQcmWshMWWivQ/HWdMd8SrApT4x 6/M15hK1QnnQGglRS7kGQL3MjBJRumX87PUjmc0Lr/LcjcSDxcly3Pe9IfKJlfT95Q7z +PBaS9DuCWlPewB0vVqhJDPRuSrX1Yg7nNAnatHM5ep0II1v0+lA6MFf0utxjjMJit13 ud6NXaO8pCdHSqwUnoK2L9+jlH/24Qs8JgZIOqbjwsCjqyJ6NB/+v2nlJgf6FqEt6eLU /uBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=MztOw9im; 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 g10-v6si2611753edi.309.2018.07.18.02.41.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 02:41:34 -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=MztOw9im; 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 163B9A60; Wed, 18 Jul 2018 11:41:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1531906883; bh=ZUviePOIgsE5gr4utevp7AAlceBk2UMlvJXiUAzZDAo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MztOw9imKgaTENbiS0VRAacS+lh/yq9ctFrTNRKkoKbhI/RTF3fjPAj5jI8/f0amm naDq2xLzEeiX03dp9OnX3l8Sq1E5gSJ2sdpo+5nHDmBe3R0BFSvC0h9ilG7A0Oo9Gt 4Dj+7ILabM6Q0Wm9nahIAI8OsLFCGAYdAOPaw0Qzy6c+t1bIaQqM2V+WFwMN3Vmgkv v6sEo+/sxjUnZAyavj+ckTgyXVEf4An0q5hfw++4V/HCo+zSz3O3Z2O0wChVEjhd45 OVzc8zMFDx8fZ2SE9zyg8ZshPSIVr3NHNZ04En3woOQJb5V/V1NtrsWlRfiWL7F2UY VNAXsPce646+g== 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, 18 Jul 2018 11:41:01 +0200 Message-Id: <1531906876-13451-25-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531906876-13451-1-git-send-email-joro@8bytes.org> References: <1531906876-13451-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;