linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com>
To: Chengguang Xu <cgxu519@mykernel.net>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	David Howells <dhowells@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] hugetlbfs: fix error handling in init_hugetlbfs_fs()
Date: Mon, 28 Oct 2019 14:27:01 -0700	[thread overview]
Message-ID: <ba6cd4a4-a1cd-82c0-5ea1-5e20112f8f6b@oracle.com> (raw)
In-Reply-To: <20191017103822.8610-1-cgxu519@mykernel.net>

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 <cgxu519@mykernel.net>

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 <mike.kravetz@oracle.com>
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 <cgxu519@mykernel.net>
Fixes: 32021982a324 ("hugetlbfs: Convert to fs_context")
Cc: stable@vger.kernel.org
Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 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



  parent reply	other threads:[~2019-10-28 21:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17 10:38 Chengguang Xu
2019-10-18  0:08 ` Mike Kravetz
2019-10-18  0:47   ` Mike Kravetz
2019-10-28 21:27 ` Mike Kravetz [this message]
2019-10-29  4:36   ` Chengguang Xu
2019-10-29 20:47     ` Mike Kravetz
2019-10-29 22:24       ` Andrew Morton
2019-10-29 22:36         ` Mike Kravetz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ba6cd4a4-a1cd-82c0-5ea1-5e20112f8f6b@oracle.com \
    --to=mike.kravetz@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgxu519@mykernel.net \
    --cc=dhowells@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox