From patchwork Wed Nov 28 11:29:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10702425 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 6CCE013BB for ; Wed, 28 Nov 2018 11:33:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C8082D06E for ; Wed, 28 Nov 2018 11:33:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 507ED2D082; Wed, 28 Nov 2018 11:33: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,UNPARSEABLE_RELAY 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 2EE4A2D06E for ; Wed, 28 Nov 2018 11:33:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9AAA6B4CB7; Wed, 28 Nov 2018 06:33:06 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E43746B4CB8; Wed, 28 Nov 2018 06:33:06 -0500 (EST) 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 D14116B4CB9; Wed, 28 Nov 2018 06:33:06 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 8EE886B4CB7 for ; Wed, 28 Nov 2018 06:33:06 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id t72so9768157pfi.21 for ; Wed, 28 Nov 2018 03:33:06 -0800 (PST) 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; bh=9awCDh/F4RqCykUYSDOODF0UJQVWHdANg4FkFF5Ghz8=; b=MJ5uONgbPsh0eQuAwZIRpdmnSpH4/5tP3vN/XKygMfI9IPNlh5o2BEi9SpkNTkQzlf iDjryU6wL9qtlnc/CQNXIZsNvSf9cBrCneK0pkzSrDbiXM8Z8+8qJ9+4hQbUmTO3t57g TARJoWz9xjCJ74xCxf8/lPDSBT2qcutzitI7iPgIoVWi0ejcqmLF61EtiHaq96WYZq7h baaRbkCquftQywhqYcPUYqiCWPvgavvk2gQJrQ9XW8rxKi/wWWS3lsFT2y1zoKvgwggf FIZArsDps1NOp6A7Njkc0dyZT8NObo77kaOzjYM3fBcX1m41Fd6Q3+SEBGUvv9qjkFrn LKvw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of alex.shi@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=alex.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Gm-Message-State: AA+aEWZ/ML1k/FBdQuoRFj2caYFhOFPHPCg4C5vZErRKX/covRFAE6qn 9hmC5tzn2hMUAnWz3SmbmrodSFKUV6ogsSiIDtnwdbpzT9limuNdqPScXfREFZzQwRCMY1AlEN5 sQa9sz5r+KDXBGiZJzbRkF0fqUL6L7ix2M2JW4F/EDvSVmfluPzTHRaYPzqG5qpQ69Q== X-Received: by 2002:a63:6bc1:: with SMTP id g184mr33505088pgc.25.1543404786183; Wed, 28 Nov 2018 03:33:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vmv8tiqA2nnAC/w1MyXueYl6yQSK78uBRAg/ZBlzRAfUE/A6RPGuHZyOEOu2VIvjl7DAGN X-Received: by 2002:a63:6bc1:: with SMTP id g184mr33505025pgc.25.1543404785217; Wed, 28 Nov 2018 03:33:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543404785; cv=none; d=google.com; s=arc-20160816; b=Uqk8oWq76q0RWcH0svJB4X+ZITYo/Z48ZhHbkv7Q2fRGAWPtgvVRq350JB1YrfKJ+E mPC60Y3N+Sqdafce//8MwELsFq8tJ84Cqg8H7ZAWYfen1Y0qkP2imwFMDvnyoP7s/+Sz GTAR/4m8otFKnc8VZn1/dDn9hKDFCgnMJQoJG18sVSdR24yZldocnSVIcenHSP2cXW3P hJ5HEwZ+AbmRSJuBJ7DgqHllwzcNjR58nbOg8HnbZVIAzMnePXEgHJZN6qIIsnQj26Xl 4TxSmolzW1PyBa6gz2ni/oKPwJBpipAN9jbQpcCObstHf7TOWrAwTNJh0DfDQX2CpcoK 80fQ== 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; bh=9awCDh/F4RqCykUYSDOODF0UJQVWHdANg4FkFF5Ghz8=; b=GJ3VoWfYkXwwWxQc30slrp6BupvZC+l7ggSFBi5zu4lldCS8rqSj+N1YTvkEV/gmYn ezr1+GOouYVpiLikdOrYKvZjGcpdB3JLsytwL2FjhYrfhz8Wf1ee4YQWLwug7zRcuPhZ A+466DksXCjyLLIJ3BEtF7VQueR+gBMhjQx9BIEMScuLTGwHckvmUTraBAsAQpZMqmGW RBYoiMA0Da7QqtBqeiEfl/Pmoh4nX3WieYIQQptRVtHSYNiSUgUVbLLjh2+l56Kx7gSX arOzQP5T5IXHaA4EtYgNDSfW7t7whTgBDmll2rpJ/UXRzCAdU2AxseWXk7qXle3r9P7D G+ZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of alex.shi@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=alex.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com. [115.124.30.132]) by mx.google.com with ESMTPS id x10si6789973pgl.209.2018.11.28.03.33.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Nov 2018 03:33:05 -0800 (PST) Received-SPF: pass (google.com: domain of alex.shi@linux.alibaba.com designates 115.124.30.132 as permitted sender) client-ip=115.124.30.132; Authentication-Results: mx.google.com; spf=pass (google.com: domain of alex.shi@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=alex.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R831e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04394;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0TEBhbtq_1543404780; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0TEBhbtq_1543404780) by smtp.aliyun-inc.com(127.0.0.1); Wed, 28 Nov 2018 19:33:01 +0800 From: Alex Shi To: Yang Shi , Michael Wang , Xunlei Pang Cc: Dexuan Cui , "K. Y. Srinivasan" , Haiyang Zhang , gregkh@linuxfoundation.org, linux-mm@kvack.org, olaf@aepfle.de, apw@canonical.com, jasowang@redhat.com, dave.hansen@intel.com, riel@redhat.com, stable@vger.kernel.org, Thomas Gleixner , Alex Shi Subject: [PATCH 008/216] x86, pageattr: Prevent overflow in slow_virt_to_phys() for X86_PAE Date: Wed, 28 Nov 2018 19:29:20 +0800 Message-Id: <1543404768-89470-8-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1543404768-89470-1-git-send-email-alex.shi@linux.alibaba.com> References: <1543404768-89470-1-git-send-email-alex.shi@linux.alibaba.com> 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: Dexuan Cui commit d1cd1210834649ce1ca6bafe5ac25d2f40331343 upstream. pte_pfn() returns a PFN of long (32 bits in 32-PAE), so "long << PAGE_SHIFT" will overflow for PFNs above 4GB. Due to this issue, some Linux 32-PAE distros, running as guests on Hyper-V, with 5GB memory assigned, can't load the netvsc driver successfully and hence the synthetic network device can't work (we can use the kernel parameter mem=3000M to work around the issue). Cast pte_pfn() to phys_addr_t before shifting. Fixes: "commit d76565344512: x86, mm: Create slow_virt_to_phys()" Signed-off-by: Dexuan Cui Cc: K. Y. Srinivasan Cc: Haiyang Zhang Cc: gregkh@linuxfoundation.org Cc: linux-mm@kvack.org Cc: olaf@aepfle.de Cc: apw@canonical.com Cc: jasowang@redhat.com Cc: dave.hansen@intel.com Cc: riel@redhat.com Cc: stable@vger.kernel.org Link: http://lkml.kernel.org/r/1414580017-27444-1-git-send-email-decui@microsoft.com Signed-off-by: Thomas Gleixner Signed-off-by: Greg Kroah-Hartman Signed-off-by: Alex Shi --- 7u/arch/x86/mm/pageattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/7u/arch/x86/mm/pageattr.c b/7u/arch/x86/mm/pageattr.c index 4ed2b2d..81b82f4 100644 --- a/7u/arch/x86/mm/pageattr.c +++ b/7u/arch/x86/mm/pageattr.c @@ -405,7 +405,7 @@ phys_addr_t slow_virt_to_phys(void *__virt_addr) psize = page_level_size(level); pmask = page_level_mask(level); offset = virt_addr & ~pmask; - phys_addr = pte_pfn(*pte) << PAGE_SHIFT; + phys_addr = (phys_addr_t)pte_pfn(*pte) << PAGE_SHIFT; return (phys_addr | offset); } EXPORT_SYMBOL_GPL(slow_virt_to_phys);