Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3982054ybg; Mon, 28 Oct 2019 23:53:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqxcblK0dbFuN5zUe0fO9VsGC2+tRQ6BfX6r2IVr2cH7VloHlq915AMMOTt2m0JFD3FUVk4D X-Received: by 2002:a17:906:b2c1:: with SMTP id cf1mr1580342ejb.155.1572332037343; Mon, 28 Oct 2019 23:53:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572332037; cv=none; d=google.com; s=arc-20160816; b=h2rCsfk36VBVVzXpYzJahk8B/mTBeb9kVpcmNn2mI1kc288ggWhowWNNmYyu+fbQWC tiaCpyKvNbHUHGFpfVWFX9hyKQridG0xHZtvZP7l0nfyo2xKvDBJ7pZ+d3A2jsiD6D47 IGF+s7gToRAck+C/hqGXQdvXSODpFjWgNVQRH3iTxzCDqBV3HYjXVUZf/fkP+no4PiRO IFi3GPYlNb3/VwS4HEfgjOS62mMrr8lnMCvIWpPSRxqJSfMo2RAj8ONEWfzP+FgiwHtf 2Jv9ZY88rBNX5I336RsTq9Ko6hqTZVwnvGmpXCpYS8Ey1yIBtjC/1vU6Rnb7S8m0F/zl TLsA== 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:from:references:cc:to:subject:dkim-signature; bh=PW9pf13B0pYFKcplz7rhY3fpsO99QodYsDktraAILi8=; b=x4IdF9bHAscfuCUZoEbUmsEvIvY0ix+uD/YkV9B0Dnw2dpysVaFKILuzEPx/JPhS31 k5NzReN8HnXeOB8zht+E9nvt/MhBauaIsB6ITjO9tpckK3354uzau+wNXlk8Wvo3oT5q RRVrgEXspjsgYRTkgnla0gpcXRorx5ynnfJfK3OAHI1gqqfvo94YvIWYWqBi1dzPrv4W ym0mbgSNYgsOKwrtTC3iE81KEb74JcPfQXdZGRt59YOri+n5lIMZTuQl8U3VBbXIhFhP R4+/7s+jcdP+x3UMEpUwgbspAFcYEVIQ73AYSs8tTanv72tOaR4kAMY53DNIqH0VW1Xx 0rtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=LDp32IYa; 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 z15si8545302edd.8.2019.10.28.23.53.33; Mon, 28 Oct 2019 23:53:57 -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-2019-08-05 header.b=LDp32IYa; 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 S1729317AbfJ1V1X (ORCPT + 99 others); Mon, 28 Oct 2019 17:27:23 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:55562 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725840AbfJ1V1W (ORCPT ); Mon, 28 Oct 2019 17:27:22 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9SLA8wS108048; Mon, 28 Oct 2019 21:27:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2019-08-05; bh=PW9pf13B0pYFKcplz7rhY3fpsO99QodYsDktraAILi8=; b=LDp32IYaHeNpv+a0AVzfRNuLxCWY+8UWwn35oJoo6w7phQqfAQtODbigzHgzZnwwbMbD UTW5nJlF/JFAmDhyrENgxT8DzbQKUwbMIbzPoTkv+GWjbLUtx2CmlNNmrn8IDTEGSj+1 3MSkAVsoDTl+kTsJTKaHzlQo7Rz3XfqIyY0QEmnvCogLpCWF6hWoyJ7eKt3LU9Xwqk3z mTaN2YGyWuqSaO1f9SCpO/YM4XywoTqSTsi1o815H09US63UuI1Jnf/QnBR06axRCC3k B00/H3j/5S4HiXMuQ3ZVpmE92GKQqzbb5qtoxYzaUwefiVMkSHWuKtQ2dzVWRVNzxmn/ Vw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2vvdju4w80-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Oct 2019 21:27:05 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9SLDCo5126307; Mon, 28 Oct 2019 21:27:05 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2vw09gg7h6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Oct 2019 21:27:05 +0000 Received: from abhmp0021.oracle.com (abhmp0021.oracle.com [141.146.116.27]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x9SLR2E2008538; Mon, 28 Oct 2019 21:27:02 GMT Received: from [192.168.1.222] (/71.63.128.209) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 28 Oct 2019 14:27:02 -0700 Subject: Re: [PATCH] hugetlbfs: fix error handling in init_hugetlbfs_fs() To: Chengguang Xu Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, David Howells , Andrew Morton References: <20191017103822.8610-1-cgxu519@mykernel.net> From: Mike Kravetz Message-ID: Date: Mon, 28 Oct 2019 14:27:01 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <20191017103822.8610-1-cgxu519@mykernel.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9424 signatures=668685 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-1908290000 definitions=main-1910280200 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9424 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910280200 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/17/19 3:38 AM, Chengguang Xu wrote: > In order to avoid using incorrect mnt, we should set > mnt to NULL when we get error from mount_one_hugetlbfs(). > > Signed-off-by: Chengguang Xu Thanks for noticing this issue. As mentioned in a previous e-mail, there are additional issues that need to be addressed. This loop needs to initialize entries in the hugetlbfs_vfsmount array for all hstates. How about this patch? From 3144f0a9d18f1408e831fb3eb49a06636a11d902 Mon Sep 17 00:00:00 2001 From: Mike Kravetz Date: Mon, 28 Oct 2019 14:08:42 -0700 Subject: [PATCH] mm/hugetlbfs: fix error handling when setting up mounts It is assumed that the hugetlbfs_vfsmount[] array will contain either a valid vfsmount pointer or NULL for each hstate after initialization. Changes made while converting to use fs_context broke this assumption. Reported-by: Chengguang Xu Fixes: 32021982a324 ("hugetlbfs: Convert to fs_context") Cc: stable@vger.kernel.org Signed-off-by: Mike Kravetz --- fs/hugetlbfs/inode.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index a478df035651..178389209561 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1470,15 +1470,17 @@ static int __init init_hugetlbfs_fs(void) i = 0; for_each_hstate(h) { mnt = mount_one_hugetlbfs(h); - if (IS_ERR(mnt) && i == 0) { + if (IS_ERR(mnt)) { + hugetlbfs_vfsmount[i] = NULL; error = PTR_ERR(mnt); - goto out; + } else { + hugetlbfs_vfsmount[i] = mnt; } - hugetlbfs_vfsmount[i] = mnt; i++; } - return 0; + if (hugetlbfs_vfsmount[default_hstate_idx] != NULL) + return 0; out: kmem_cache_destroy(hugetlbfs_inode_cachep); -- 2.20.1