This is a note to let you know that I've just added the patch titled mm/hugetlbfs: fix for_each_hstate() loop in init_hugetlbfs_fs() to the 5.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: mm-hugetlbfs-fix-for_each_hstate-loop-in-init_hugetlbfs_fs.patch and it can be found in the queue-5.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 15f0ec941f4f908fefa23a30ded8358977cc1cc0 Mon Sep 17 00:00:00 2001 From: Jan Stancek <jstancek@xxxxxxxxxx> Date: Fri, 3 Jan 2020 18:37:18 +0100 Subject: mm/hugetlbfs: fix for_each_hstate() loop in init_hugetlbfs_fs() From: Jan Stancek <jstancek@xxxxxxxxxx> commit 15f0ec941f4f908fefa23a30ded8358977cc1cc0 upstream. LTP memfd_create04 started failing for some huge page sizes after v5.4-10135-gc3bfc5dd73c6. The problem is the check introduced to for_each_hstate() loop that should skip default_hstate_idx. Since it doesn't update 'i' counter, all subsequent huge page sizes are skipped as well. Fixes: 8fc312b32b25 ("mm/hugetlbfs: fix error handling when setting up mounts") Signed-off-by: Jan Stancek <jstancek@xxxxxxxxxx> Reviewed-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx> Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/hugetlbfs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1478,8 +1478,10 @@ static int __init init_hugetlbfs_fs(void /* other hstates are optional */ i = 0; for_each_hstate(h) { - if (i == default_hstate_idx) + if (i == default_hstate_idx) { + i++; continue; + } mnt = mount_one_hugetlbfs(h); if (IS_ERR(mnt)) Patches currently in stable-queue which might be from jstancek@xxxxxxxxxx are queue-5.4/mm-hugetlbfs-fix-for_each_hstate-loop-in-init_hugetlbfs_fs.patch queue-5.4/iomap-fix-return-value-of-iomap_dio_bio_actor-on-32b.patch