Received: by 10.213.65.68 with SMTP id h4csp993725imn; Wed, 28 Mar 2018 17:44:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/w178Mn0ByQ5wTlEljeF5CYee0glB6On4KAacau0Lz5OC0D7XKUwplshJgMPbeusnj6ukA X-Received: by 2002:a17:902:850c:: with SMTP id bj12-v6mr6016287plb.110.1522284246383; Wed, 28 Mar 2018 17:44:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522284246; cv=none; d=google.com; s=arc-20160816; b=iPJW2bpqSoCOXsYdzBYATCyGybXekNiOIvDGXukaSjGNGlUMtdgnbnmsR3ym4dIAZR vq3E3vkuXRgRCIdSrraBcnH8yEWfQt4EGidMk66N0KYDuUsE13VkP1rEF85o89j/peEP P585teQqwZrhX1Bdra/ybQ61yGw98j/oezJBvF/oWKHkOTWJoaCZWkMbJFC14RupQOd2 q7Tq3bzo+E//m/FSo6pMIpAXrKVSwrpm4OKHMxfiTZdo6nUqnjRIVNMEhmXBJObzFNRi v4RskaAO6LgzOI3yzyPMy9fXABawUQwQrsOk5QqYUmFuGIQq0Gz9fiSg0JSRtnALFqM6 x9qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:to:from:subject:dkim-signature :arc-authentication-results; bh=pDL9Z3CF8s1LoaLJVkZAkw8aUV2X29D2e6sPd0Rwycs=; b=fvc2wm6UMM3sv9fQjImkINbGyxspuU5rWnuYKsVz+hjhnxx5nuG28aTlbZh9U1SKGi CDzDvGkbBO9Ruwr/q8Xl9gTe0IF40ZjAwDysqHWQuWvCIF5rl0mA1pUKx/FmDNsaHZR9 n9Z45c2zLV8WgVYJ8oZWJ1K8c6wJmpsVOS7ntMxyTxghKzgOBqRPoZ/sjoLlj8AGWX2j OVlirHb3qcQSZUtmk6r5qSwWnolj5Sp4ihTg/+bSJ5TX9RHZhhwtTrNzxBbnZT8wV3tN qbb7gKjpxF+hqSFIRgegb4ZxsEKVkTxIt2W292SBA6bGWiJ39KR91hfBDLhUX+4N5jc6 bM8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=sxc21UN4; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t9si3574967pfh.101.2018.03.28.17.43.51; Wed, 28 Mar 2018 17:44:06 -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=@oracle.com header.s=corp-2017-10-26 header.b=sxc21UN4; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751172AbeC2Am7 (ORCPT + 99 others); Wed, 28 Mar 2018 20:42:59 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:38050 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750866AbeC2Am5 (ORCPT ); Wed, 28 Mar 2018 20:42:57 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2T0NsbJ114847; Thu, 29 Mar 2018 00:42:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : references : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=pDL9Z3CF8s1LoaLJVkZAkw8aUV2X29D2e6sPd0Rwycs=; b=sxc21UN4DHxWI6rBuGPUBmY96MVPx8f3YOYEkta4CZcCmQsOzbB0CkBFT1Jyw3s/bLUM h70iwy96aiNW+w55dlbLDRSlCP8ar/QMArgPy5MNxqg5GxdIkoWcIUb3NHBq2pvQlnqC E3ktE/+jvcxfk1K76CbP5parivjUX5enTikrIj5HeD75degTIXcCRlOmcKc7dLFMu+Jl pzNYJlxBF1vW4qB/qByoISeDljkVAnFg5l5amY4KtjPdCDFL1wmedGMlZQVO6uLycF+1 yzgC/t674Rjg52YImpcaWfr9rudCW2Q62Zlet9JxFClzqqvs7UNODEW1/JaUTpsLU7M/ 3g== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2h0njhg12h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Mar 2018 00:42:22 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w2T0gLv3028455 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Mar 2018 00:42:21 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w2T0gJXs023159; Thu, 29 Mar 2018 00:42:19 GMT Received: from [192.168.1.164] (/98.246.252.205) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 28 Mar 2018 17:42:19 -0700 Subject: Re: [PATCH 4.15 000/105] 4.15.14-stable review From: Mike Kravetz To: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, akpm@linux-foundation.org, linux@roeck-us.net, shuahkh@osg.samsung.com, patches@kernelci.org, ben.hutchings@codethink.co.uk, lkft-triage@lists.linaro.org, stable@vger.kernel.org References: <20180327162757.813009222@linuxfoundation.org> <20180328184423.44nhfdfy26l37b5p@xps> <12e0d7ea-4d62-41bf-40fa-e6005460c9b6@oracle.com> Message-ID: Date: Wed, 28 Mar 2018 17:42:17 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <12e0d7ea-4d62-41bf-40fa-e6005460c9b6@oracle.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8846 signatures=668695 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803280244 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/28/2018 12:06 PM, Mike Kravetz wrote: > On 03/28/2018 11:44 AM, Dan Rue wrote: >> On Tue, Mar 27, 2018 at 06:26:40PM +0200, Greg Kroah-Hartman wrote: >>> This is the start of the stable review cycle for the 4.15.14 release. >>> There are 105 patches in this series, all will be posted as a response >>> to this one. If anyone has any issues with these being applied, please >>> let me know. >>> >>> Responses should be made by Thu Mar 29 16:27:29 UTC 2018. >>> Anything received after that time might be too late. >> >> Results from Linaro’s test farm. >> No regressions on arm64 and x86_64. >> >> There is a regression on arm32 in libhugetlbfs/truncate_above_4GB-2M-32 >> that also exists in 4.14 and mainline. We'll investigate the root cause >> and report upstream in mainline. I suspect the cause is "hugetlbfs: >> check for pgoff value overflow", but have not verified yet. > > I'll also take a look as this was a patch I introduced. I do not have an arm32 system to test, but am fairly confident the commit 63489f8e8211 (hugetlbfs: check for pgoff value overflow) introduced this regression. A new mask was added to check PGOFF for overflow of a lofft. /* * Mask used when checking the page offset value passed in via system * calls. This value will be converted to a loff_t which is signed. * Therefore, we want to check the upper PAGE_SHIFT + 1 bits of the * value. The extra bit (- 1 in the shift value) is to take the sign * bit into account. */ #define PGOFF_LOFFT_MAX \ (((1UL << (PAGE_SHIFT + 1)) - 1) << (BITS_PER_LONG - (PAGE_SHIFT + 1))) This mask incorrectly used BITS_PER_LONG as the size of a loff_t. This is true on 64 bit, but not 32 bit systems. As a result, mmap of hugetlbfs file offsets near 4GB will fail. I suspect the mmap64 call in the test libhugetlbfs/truncate_above_4GB was the source of the failure. Can you try the following on arm32? I will try to set up a 32 bit x86 system to test as well. But, it may take me a bit of time. diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index b9a254dcc0e7..8450a1d75dfa 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -116,7 +116,8 @@ static void huge_pagevec_release(struct pagevec *pvec) * bit into account. */ #define PGOFF_LOFFT_MAX \ - (((1UL << (PAGE_SHIFT + 1)) - 1) << (BITS_PER_LONG - (PAGE_SHIFT + 1))) + (((1UL << (PAGE_SHIFT + 1)) - 1) << \ + ((sizeof(loff_t) * BITS_PER_BYTE) - (PAGE_SHIFT + 1))) static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) { @@ -138,21 +139,32 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) /* * page based offset in vm_pgoff could be sufficiently large to - * overflow a (l)off_t when converted to byte offset. + * overflow a loff_t when converted to byte offset. */ - if (vma->vm_pgoff & PGOFF_LOFFT_MAX) + if ((loff_t)vma->vm_pgoff & (loff_t)PGOFF_LOFFT_MAX) return -EINVAL; - /* must be huge page aligned */ + /* vm_pgoff must be huge page aligned */ if (vma->vm_pgoff & (~huge_page_mask(h) >> PAGE_SHIFT)) return -EINVAL; + /* + * Compute file offset of the end of this mapping + */ vma_len = (loff_t)(vma->vm_end - vma->vm_start); len = vma_len + ((loff_t)vma->vm_pgoff << PAGE_SHIFT); - /* check for overflow */ + + /* Check to ensure this did not overflow loff_t */ if (len < vma_len) return -EINVAL; + /* + * On 32 bit systems, this check is necessary to ensure the last page + * of mapping can be represented as a signed long huge page index. + */ + if ((len >> huge_page_shift(h)) > LONG_MAX) + return -EINVAL; + inode_lock(inode); file_accessed(file); -- Mike Kravetz