Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp839129img; Mon, 18 Mar 2019 15:48:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9z+SuJc7X8CR/Qs4wLBcQQRoFhWuEhcX1CV86iXk8HrwuVeN8MLqPLTQQYq7ncmu/LglQ X-Received: by 2002:a62:4553:: with SMTP id s80mr21225611pfa.141.1552949323336; Mon, 18 Mar 2019 15:48:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552949323; cv=none; d=google.com; s=arc-20160816; b=t32ZtZBhAJFIr1bECLaBA0Ly9xw7YbyhYs1QH5917h+AOFXpPFaHcyGsLXMzM0U3mf LIfcXRspgFiW7bACLQz6pEd11BDuyNMBGj0SzggGQYjcZvpqplRvEJMMCsmKN+1Tt99F wAmFGgmyxAM6IZjxc0BbFPyH+9C5I6X4cG2lT1+IuO54QNKigZvSJ487RiZBZgmdDzRu cjdphlsBJVbhCoqnAgIh5MGUp17TGhNAMfs1BDBNthVT/gNdQ1lX3TXAohBFGh3g4r8j xd8ZIpRLDDUnCOXtcbgvtIvaPtxVhOXPfcIVqyZv3j2ZKbCapW0GtZvX1DpaxGrY4XDK wISQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=B8TqZYzUiNm2o9lJaKdlFCUI9JnPax1W6w227rOcK0M=; b=mPTk2OHSIz2qTYKbUUVp5DVbfZNUHoue6HoDGwA7S5a+eGUg8W0OaD2VE+xkloSZqb W0k48gsOMXdr5Cb3vTGtHDvTvdDV3MOfWQpCQkP0KMmNi2O31VQf+2wvw8wdV+sHgvzd pxRRjeRZdewAVRRTauTvTDVEDPua6avZtzW42+4Ugq0Fr9iUriH0UNgroK2iFLb6Z4Nm +ewiCVrO/t+tNzLK0bwag1ZrqW8WbmV3FpoclISf/2eDSBugWQCEuxlnT64VJb12uM0Z 83OVtyNo8E96M82keqVgF1JJT12tIFLWDYXhaXo+R+mc3ucUnezL7ezHv+/fKd8OfmR0 dnDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=FOD+vlL0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q12si10598840pli.428.2019.03.18.15.48.28; Mon, 18 Mar 2019 15:48:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=FOD+vlL0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727472AbfCRWrY (ORCPT + 99 others); Mon, 18 Mar 2019 18:47:24 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:4548 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726953AbfCRWrX (ORCPT ); Mon, 18 Mar 2019 18:47:23 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 18 Mar 2019 15:47:24 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Mon, 18 Mar 2019 15:47:22 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Mon, 18 Mar 2019 15:47:22 -0700 Received: from rcampbell-dev.nvidia.com (10.124.1.5) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 18 Mar 2019 22:47:22 +0000 From: To: CC: Ralph Campbell , Craig Bergstrom , Linus Torvalds , Boris Ostrovsky , Fengguang Wu , Greg Kroah-Hartman , Hans Verkuil , Mauro Carvalho Chehab , Peter Zijlstra , Sander Eikelenboom , Sean Young , Thomas Gleixner , Ingo Molnar Subject: [PATCH 1/1] x86/mm: Fix limit mmap() of /dev/mem to valid physical addresses Date: Mon, 18 Mar 2019 15:46:53 -0700 Message-ID: <20190318224653.26549-2-rcampbell@nvidia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190318224653.26549-1-rcampbell@nvidia.com> References: <20190318224653.26549-1-rcampbell@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL101.nvidia.com (172.20.187.10) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1552949244; bh=B8TqZYzUiNm2o9lJaKdlFCUI9JnPax1W6w227rOcK0M=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-NVConfidentiality: X-Originating-IP:X-ClientProxiedBy:Content-Transfer-Encoding: Content-Type; b=FOD+vlL0/kNAqVsy0VnxCTwyhQH3A0Yp80kuqNlKXrjuIUOQAjMZn44k4q//Yj5tV qOsdAw0saz4drD/KpmrX2EocDSj7cBVz4n8pTKt13UZrDpq+kTyzneDr2ouLR2u9tu ljTOUKiU/cYXS2fKHYUmf9tXDE+hfVnTJ2dGG2jmAXfT6ZSu4Hxq9VLPIDKw0Z/aBx +C5rtB0W6ooWwHNCzZosW7jLdF2YKgeGHQeDz1UeBBnwBgvKdWWKiIZcc7gr8r1oYk qBcvzaxygM94P3lNeXxkraBOm1KFzy6Bs4qt2FraJzR8J0ugyX7dBGPwCKpD8dmhCi jjqY8kJrPAaCA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ralph Campbell If CONFIG_DEBUG_VIRTUAL is enabled, a read or write to /dev/mem can trigger a VIRTUAL_BUG_ON() depending on the value of high_memory. For example: read_mem() valid_phys_addr_range(p=3D401f1550, count=3D8) __pa(high_memory) __phys_addr(x=3Dffffc88000000000) // __START_KERNEL_map =3D ffffffff80000000 // y =3D ffffc88000000000 - ffffffff80000000 VIRTUAL_BUG_ON(phys_addr_valid(400000000000)) // boot_cpu_data.x86_phys_bits=3D46 Since by design high_memory is outside the range of valid physical addresses, use the non-error checking version __pa_nodebug(high_memory). Fixes: be62a32044061cb4a3b70a10598e093f1319102e ("x86/mm: Limit mmap() of /dev/mem to valid physical addresses") Signed-off-by: Ralph Campbell Cc: Craig Bergstrom Cc: Linus Torvalds Cc: Boris Ostrovsky Cc: Fengguang Wu Cc: Greg Kroah-Hartman Cc: Hans Verkuil Cc: Mauro Carvalho Chehab Cc: Peter Zijlstra Cc: Sander Eikelenboom Cc: Sean Young Cc: Thomas Gleixner Cc: Ingo Molnar --- arch/x86/mm/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c index db3165714521..196bed43d5e6 100644 --- a/arch/x86/mm/mmap.c +++ b/arch/x86/mm/mmap.c @@ -230,7 +230,7 @@ bool mmap_address_hint_valid(unsigned long addr, unsign= ed long len) /* Can we access it for direct reading/writing? Must be RAM: */ int valid_phys_addr_range(phys_addr_t addr, size_t count) { - return addr + count <=3D __pa(high_memory); + return addr + count <=3D __pa_nodebug(high_memory); } =20 /* Can we access it through mmap? Must be a valid physical address: */ --=20 2.20.1