From patchwork Mon May 20 23:38:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rick Edgecombe X-Patchwork-Id: 10952685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D132912 for ; Mon, 20 May 2019 23:39:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECDF028800 for ; Mon, 20 May 2019 23:39:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD75D28913; Mon, 20 May 2019 23:39:09 +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=-2.9 required=2.0 tests=BAYES_00,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 4D57428800 for ; Mon, 20 May 2019 23:39:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EDE446B0005; Mon, 20 May 2019 19:39:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E68AA6B0006; Mon, 20 May 2019 19:39:06 -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 C6D506B0007; Mon, 20 May 2019 19:39:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id 8F3FD6B0005 for ; Mon, 20 May 2019 19:39:06 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id 14so10759553pgo.14 for ; Mon, 20 May 2019 16:39:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Ds3H9F2HKk2YdGjewRFDhvqdq1umWShX+MEkRxlhmj4=; b=e6D+AH45p3ZgPacH6qSl29QsP9jpcHbo85ZW+xGai2sWlFNuum+h0za+x72z42wV9p WX9PJyQaZokkPnSNF4FzEIuKjjOvJx5oN0fE+G0o4/XvG/G/ppZieXmEkZWGmSkzmVM+ l1f9CBJDmB68qcxnXXZkrbMPhtdFztIVUj+u3fKkUR5RmiyteNEUTiyshhuKD1kEkbVc 1YZ9HcdOtj/m2f6EEzuRz9kukggsBXDeFtEIRMfwDgO2auS4QnJEPSNQNUmTK+NUpY8z qd7eaoKf4lbE2qzHuYgRz9fZriWKuhdskcKghC1gUXvQod1EJpbCsrwy3jpdnQ/vaig/ tnqw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of rick.p.edgecombe@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=rick.p.edgecombe@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APjAAAXGYFlLLRd2gvl1YCqulhvYNz9JMUE9X1z3YTMGvsBCyNvdeGYQ qNDXll56y4cRAGvcbznqEXcUiknUAR3rSK9BAFaXaKHjLqw64bJqlJp7Hn1jkBykahowdT/K3a+ tO/1hdNLQm9DiJn6CZMH8HyGKGKghBtRd7XQYmfULkFs3k1/uknWY3VL4/7RyLg3Rwg== X-Received: by 2002:aa7:93bb:: with SMTP id x27mr82451172pff.104.1558395546249; Mon, 20 May 2019 16:39:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGf2sWAM2EmfnX4cGKnoWnAl8nbP+qowp9O7iSbRBEAIdJZzGNaZFY6Hmpsab/+A4Bk0dQ X-Received: by 2002:aa7:93bb:: with SMTP id x27mr82451116pff.104.1558395545424; Mon, 20 May 2019 16:39:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558395545; cv=none; d=google.com; s=arc-20160816; b=Y3P9X70aKa1am6RIqkOpcO+un73pfZLSwfvBDOp7x01NWbldTlRH0rFj1bJqnwaM3Q 1mQqVroIJWZqNgXqx3M3413dfkzJlOnJw5TrbiDnNcUlnRiJYrMwlhsD66aslROs4PAK iN1DuC4s6xKhXaZ3vDMO5/P9UipLlQKVwTteNz4WDCs11wJbpYhD2+4MOfXAJ6O3UKpp 1BFidXc2KfpIddJg0225vejT7kO4m81VBS6I/eP5vR6C4MweudTLN5o0dUYdGmYJckfA th6xFaHStrClfAuFcuZYxsRk8dbzJuKLRnVFNwAv/OQUHcwlYDDaO4aDMhfFfmDZf492 igog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Ds3H9F2HKk2YdGjewRFDhvqdq1umWShX+MEkRxlhmj4=; b=rGVsneN9ABD3Jf2wYWHRu/FCKxTm88R7sokUXwGWACrXxw+QSGWK1HlTUhjQ426lV/ Q9KIO8TGLzdAHo6NaWVnHTs1W0pKuTxHvdc+SZZNrCJNbcVaZBKHWb9jwgPJMhfWe9oQ 4Td63RUBqOzu6/3+0chaggiX/xiXhie6XS/q7D5WEPvpDW/+1FTHczxyUaXY3VgVtQ46 BRqga29XQhA3MywGyS1FtGeySrf8Cw2xL/gXqMjmxzEFzbocDc5T1ueHbUZVDrTHgkT6 an9MisgMy2ZXONaTLJJwY7lOWyYPTbrbDcCQsz0dPemG70XuZwJKG+DzjEoZNUOsiJgJ stBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of rick.p.edgecombe@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=rick.p.edgecombe@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga11.intel.com (mga11.intel.com. [192.55.52.93]) by mx.google.com with ESMTPS id g90si19915577plb.140.2019.05.20.16.39.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 May 2019 16:39:05 -0700 (PDT) Received-SPF: pass (google.com: domain of rick.p.edgecombe@intel.com designates 192.55.52.93 as permitted sender) client-ip=192.55.52.93; Authentication-Results: mx.google.com; spf=pass (google.com: domain of rick.p.edgecombe@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=rick.p.edgecombe@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 May 2019 16:39:05 -0700 X-ExtLoop1: 1 Received: from rpedgeco-mobl.amr.corp.intel.com (HELO localhost.intel.com) ([10.254.114.95]) by fmsmga008.fm.intel.com with ESMTP; 20 May 2019 16:39:04 -0700 From: Rick Edgecombe To: linux-kernel@vger.kernel.org, peterz@infradead.org, sparclinux@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, luto@amacapital.net Cc: dave.hansen@intel.com, namit@vmware.com, davem@davemloft.net, Rick Edgecombe , Meelis Roos , Borislav Petkov , Andy Lutomirski , Ingo Molnar , Rick Edgecombe Subject: [PATCH v2 1/2] vmalloc: Fix calculation of direct map addr range Date: Mon, 20 May 2019 16:38:40 -0700 Message-Id: <20190520233841.17194-2-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190520233841.17194-1-rick.p.edgecombe@intel.com> References: <20190520233841.17194-1-rick.p.edgecombe@intel.com> MIME-Version: 1.0 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: Rick Edgecombe The calculation of the direct map address range to flush was wrong. This could cause problems on x86 if a RO direct map alias ever got loaded into the TLB. This shouldn't normally happen, but it could cause the permissions to remain RO on the direct map alias, and then the page would return from the page allocator to some other component as RO and cause a crash. So fix fix the address range calculation so the flush will include the direct map range. Fixes: 868b104d7379 ("mm/vmalloc: Add flag for freeing of special permsissions") Cc: Meelis Roos Cc: Peter Zijlstra Cc: "David S. Miller" Cc: Dave Hansen Cc: Borislav Petkov Cc: Andy Lutomirski Cc: Ingo Molnar Cc: Nadav Amit Signed-off-by: Rick Edgecombe --- mm/vmalloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index c42872ed82ac..836888ae01f6 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2159,9 +2159,10 @@ static void vm_remove_mappings(struct vm_struct *area, int deallocate_pages) * the vm_unmap_aliases() flush includes the direct map. */ for (i = 0; i < area->nr_pages; i++) { - if (page_address(area->pages[i])) { + addr = (unsigned long)page_address(area->pages[i]); + if (addr) { start = min(addr, start); - end = max(addr, end); + end = max(addr + PAGE_SIZE, end); } }