linux/fs
Shijie Hu 8859025315 hugetlbfs: get unmapped area below TASK_UNMAPPED_BASE for hugetlbfs
In a 32-bit program, running on arm64 architecture.  When the address
space below mmap base is completely exhausted, shmat() for huge pages will
return ENOMEM, but shmat() for normal pages can still success on no-legacy
mode.  This seems not fair.

For normal pages, the calling trace of get_unmapped_area() is:

	=> mm->get_unmapped_area()
	if on legacy mode,
		=> arch_get_unmapped_area()
			=> vm_unmapped_area()
	if on no-legacy mode,
		=> arch_get_unmapped_area_topdown()
			=> vm_unmapped_area()

For huge pages, the calling trace of get_unmapped_area() is:

	=> file->f_op->get_unmapped_area()
		=> hugetlb_get_unmapped_area()
			=> vm_unmapped_area()

To solve this issue, we only need to make hugetlb_get_unmapped_area() take
the same way as mm->get_unmapped_area().  Add *bottomup() and *topdown()
for hugetlbfs, and check current mm->get_unmapped_area() to decide which
one to use.  If mm->get_unmapped_area is equal to
arch_get_unmapped_area_topdown(), hugetlb_get_unmapped_area() calls
topdown routine, otherwise calls bottomup routine.

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Shijie Hu <hushijie3@huawei.com>
Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Will Deacon <will@kernel.org>
Cc: Xiaoming Ni <nixiaoming@huawei.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: yangerkun <yangerkun@huawei.com>
Cc: ChenGang <cg.chen@huawei.com>
Cc: Chen Jie <chenjie6@huawei.com>
Link: http://lkml.kernel.org/r/20200518065338.113664-1-hushijie3@huawei.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-06-03 20:09:49 -07:00
..
9p 9p: read only once on O_NONBLOCK 2020-03-27 09:29:56 +00:00
adfs docs: filesystems: fix renamed references 2020-04-20 15:45:22 -06:00
affs docs: filesystems: fix renamed references 2020-04-20 15:45:22 -06:00
afs A fair amount of stuff this time around, dominated by yet another massive 2020-06-01 15:45:27 -07:00
autofs LOOKUP_MOUNTPOINT: fold path_mountpointat() into path_lookupat() 2020-03-13 21:08:17 -04:00
befs
bfs docs: filesystems: fix renamed references 2020-04-20 15:45:22 -06:00
btrfs for-5.8-tag 2020-06-02 19:59:25 -07:00
cachefiles A fair amount of stuff this time around, dominated by yet another massive 2020-06-01 15:45:27 -07:00
ceph ceph: flush release queue when handling caps for unknown inode 2020-05-27 13:03:57 +02:00
cifs mm: fold and remove lru_cache_add_anon() and lru_cache_add_file() 2020-06-03 20:09:48 -07:00
coda docs: filesystems: convert coda.txt to ReST 2020-05-05 09:22:21 -06:00
configfs A fair amount of stuff this time around, dominated by yet another massive 2020-06-01 15:45:27 -07:00
cramfs docs: filesystems: fix renamed references 2020-04-20 15:45:22 -06:00
crypto fscrypt updates for 5.8 2020-06-01 12:10:17 -07:00
debugfs debugfs: remove return value of debugfs_create_u32() 2020-04-17 17:08:50 +02:00
devpts
dlm
ecryptfs A fair amount of stuff this time around, dominated by yet another massive 2020-06-01 15:45:27 -07:00
efivarfs efi: Use more granular check for availability for variable services 2020-02-23 21:59:42 +01:00
efs
erofs Changes since last update: 2020-06-02 20:16:55 -07:00
exfat fs: convert mpage_readpages to mpage_readahead 2020-06-02 10:59:07 -07:00
exportfs
ext2 fs: convert mpage_readpages to mpage_readahead 2020-06-02 10:59:07 -07:00
ext4 for-5.8/block-2020-06-01 2020-06-02 15:29:19 -07:00
f2fs f2fs: use attach/detach_page_private 2020-06-02 10:59:07 -07:00
fat for-5.8/block-2020-06-01 2020-06-02 15:29:19 -07:00
freevxfs
fscache docs: filesystems: caching/backend-api.txt: convert it to ReST 2020-05-05 09:22:21 -06:00
fuse mm: fold and remove lru_cache_add_anon() and lru_cache_add_file() 2020-06-03 20:09:48 -07:00
gfs2 mm: remove the pgprot argument to __vmalloc 2020-06-02 10:59:11 -07:00
hfs for-5.8/block-2020-06-01 2020-06-02 15:29:19 -07:00
hfsplus block: remove the error_sector argument to blkdev_issue_flush 2020-05-22 08:45:46 -06:00
hostfs hostfs: Use kasprintf() instead of fixed buffer formatting 2020-03-29 23:23:00 +02:00
hpfs Merge branch 'akpm' (patches from Andrew) 2020-06-02 12:21:36 -07:00
hugetlbfs hugetlbfs: get unmapped area below TASK_UNMAPPED_BASE for hugetlbfs 2020-06-03 20:09:49 -07:00
iomap for-5.8-tag 2020-06-02 19:59:25 -07:00
isofs for-5.8/block-2020-06-01 2020-06-02 15:29:19 -07:00
jbd2 block: remove the error_sector argument to blkdev_issue_flush 2020-05-22 08:45:46 -06:00
jffs2 fs_parse: fold fs_parameter_desc/fs_parameter_spec 2020-02-07 14:48:37 -05:00
jfs Replace zero-length array in JFS 2020-06-02 20:11:35 -07:00
kernfs kernfs: Add option to enable user xattrs 2020-03-16 15:53:47 -04:00
lockd proc: convert everything to "struct proc_ops" 2020-02-04 03:05:26 +00:00
minix
nfs mm: remove the pgprot argument to __vmalloc 2020-06-02 10:59:11 -07:00
nfs_common
nfsd mm/writeback: replace PF_LESS_THROTTLE with PF_LOCAL_THROTTLE 2020-06-02 10:59:08 -07:00
nilfs2 for-5.8/block-2020-06-01 2020-06-02 15:29:19 -07:00
nls
notify A fair amount of stuff this time around, dominated by yet another massive 2020-06-01 15:45:27 -07:00
ntfs Merge branch 'akpm' (patches from Andrew) 2020-06-02 12:21:36 -07:00
ocfs2 for-5.8/block-2020-06-01 2020-06-02 15:29:19 -07:00
omfs fs: convert mpage_readpages to mpage_readahead 2020-06-02 10:59:07 -07:00
openpromfs
orangefs orangefs: use attach/detach_page_private 2020-06-02 10:59:08 -07:00
overlayfs A fair amount of stuff this time around, dominated by yet another massive 2020-06-01 15:45:27 -07:00
proc Merge branch 'akpm' (patches from Andrew) 2020-06-02 12:21:36 -07:00
pstore Merge branch 'uaccess.__copy_from_user' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2020-06-01 16:18:46 -07:00
qnx4
qnx6 fs: convert mpage_readpages to mpage_readahead 2020-06-02 10:59:07 -07:00
quota \n 2020-01-30 15:37:41 -08:00
ramfs fs_parse: fold fs_parameter_desc/fs_parameter_spec 2020-02-07 14:48:37 -05:00
reiserfs for-5.8/block-2020-06-01 2020-06-02 15:29:19 -07:00
romfs docs: filesystems: fix renamed references 2020-04-20 15:45:22 -06:00
squashfs Merge branch 'akpm' (patches from Andrew) 2020-06-02 12:21:36 -07:00
sysfs docs: filesystems: fix renamed references 2020-04-20 15:45:22 -06:00
sysv docs: filesystems: fix renamed references 2020-04-20 15:45:22 -06:00
tracefs
ubifs mm: remove the pgprot argument to __vmalloc 2020-06-02 10:59:11 -07:00
udf for-5.8/block-2020-06-01 2020-06-02 15:29:19 -07:00
ufs
unicode .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
vboxsf vboxsf: don't use the source name in the bdi name 2020-05-07 08:45:47 -06:00
verity fs-verity: remove unnecessary extern keywords 2020-05-12 16:44:00 -07:00
xfs (More) new code for 5.8: 2020-06-02 19:48:41 -07:00
zonefs for-5.8/block-2020-06-01 2020-06-02 15:29:19 -07:00
Kconfig docs: filesystems: fix renamed references 2020-04-20 15:45:22 -06:00
Kconfig.binfmt A fair amount of stuff this time around, dominated by yet another massive 2020-06-01 15:45:27 -07:00
Makefile exfat: add Kconfig and Makefile 2020-03-05 21:00:40 -05:00
aio.c aio: fix async fsync creds 2020-05-14 16:44:24 +02:00
anon_inodes.c
attr.c
bad_inode.c
binfmt_aout.c
binfmt_elf.c Merge branch 'work.set_fs-exec' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2020-06-01 16:21:46 -07:00
binfmt_elf_fdpic.c binfmt_elf_fdpic: remove the set_fs(KERNEL_DS) in elf_fdpic_core_dump 2020-05-05 16:46:10 -04:00
binfmt_em86.c
binfmt_flat.c
binfmt_misc.c
binfmt_script.c
block_dev.c for-5.8/drivers-2020-06-01 2020-06-02 15:37:03 -07:00
buffer.c fs/buffer.c: use attach/detach_page_private 2020-06-02 10:59:07 -07:00
char_dev.c vfs: allow unprivileged whiteout creation 2020-05-14 16:44:23 +02:00
compat.c
compat_binfmt_elf.c Merge branch 'work.set_fs-exec' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2020-06-01 16:21:46 -07:00
coredump.c coredump: fix crash when umh is disabled 2020-04-28 17:54:13 +02:00
d_path.c
dax.c dax,iomap: Add helper dax_iomap_zero() to zero a range 2020-04-02 19:15:03 -07:00
dcache.c fs: Introduce DCACHE_DONTCACHE 2020-05-13 08:44:35 -07:00
dcookies.c
direct-io.c for-5.8-tag 2020-06-02 19:59:25 -07:00
drop_caches.c
eventfd.c eventfd: track eventfd_signal() recursion depth 2020-02-03 17:27:38 -07:00
eventpoll.c epoll: call final ep_events_available() check under the lock 2020-05-14 10:00:35 -07:00
exec.c exec: Move would_dump into flush_old_exec 2020-05-17 10:48:24 -05:00
fcntl.c fcntl: Distribute switch variables for initialization 2020-03-03 10:55:06 -05:00
fhandle.c
file.c fix multiplication overflow in copy_fdtable() 2020-05-19 18:29:36 -04:00
file_table.c vfs: track per-sb writeback errors and report them to syncfs 2020-06-02 10:59:05 -07:00
filesystems.c fs/filesystems.c: downgrade user-reachable WARN_ONCE() to pr_warn_once() 2020-04-10 15:36:22 -07:00
fs-writeback.c for-5.8/block-2020-06-01 2020-06-02 15:29:19 -07:00
fs_context.c vfs: don't parse "silent" option 2020-05-14 16:44:25 +02:00
fs_parser.c fs_parse: remove pr_notice() about each validation 2020-04-02 09:35:26 -07:00
fs_pin.c
fs_struct.c
fs_types.c
fsopen.c add prefix to fs_context->log 2020-02-07 14:48:35 -05:00
inode.c fs: inode.c: get rid of docs warnings 2020-04-20 15:45:41 -06:00
internal.h for-5.8/io_uring-2020-06-01 2020-06-02 15:42:50 -07:00
io-wq.c io_uring: use io-wq manager as backup task if task is exiting 2020-04-03 11:35:57 -06:00
io-wq.h io_uring: use io-wq manager as backup task if task is exiting 2020-04-03 11:35:57 -06:00
io_uring.c for-5.8/io_uring-2020-06-01 2020-06-02 15:42:50 -07:00
ioctl.c fibmap: Warn and return an error in case of block > INT_MAX 2020-04-30 07:57:46 -07:00
libfs.c block: remove the error_sector argument to blkdev_issue_flush 2020-05-22 08:45:46 -06:00
locks.c docs: filesystems: convert mandatory-locking.txt to ReST 2020-05-05 09:22:22 -06:00
mbcache.c
mount.h proc/mounts: add cursor 2020-05-14 16:44:24 +02:00
mpage.c fs: convert mpage_readpages to mpage_readahead 2020-06-02 10:59:07 -07:00
namei.c vfs: allow unprivileged whiteout creation 2020-05-14 16:44:23 +02:00
namespace.c Merge branch 'from-miklos' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2020-06-01 16:44:06 -07:00
no-block.c
nsfs.c fs/nsfs.c: Added ns_match 2020-03-12 17:33:11 -07:00
open.c Merge branch 'akpm' (patches from Andrew) 2020-06-02 12:21:36 -07:00
pipe.c mm: kmem: rename memcg_kmem_(un)charge() into memcg_kmem_(un)charge_page() 2020-04-02 09:35:28 -07:00
pnode.c propagate_one(): mnt_set_mountpoint() needs mount_lock 2020-04-27 10:37:14 -04:00
pnode.h
posix_acl.c
proc_namespace.c proc/mounts: add cursor 2020-05-14 16:44:24 +02:00
read_write.c powerpc: Add back __ARCH_WANT_SYS_LLSEEK macro 2020-04-03 00:09:59 +11:00
readdir.c readdir.c: get rid of the last __put_user(), drop now-useless access_ok() 2020-05-01 20:29:54 -04:00
select.c
seq_file.c fs/seq_file.c: seq_read(): add info message about buggy .next functions 2020-04-10 15:36:22 -07:00
signalfd.c
splice.c for-5.8/io_uring-2020-06-01 2020-06-02 15:42:50 -07:00
stack.c
stat.c New code for 5.8: 2020-06-02 19:45:12 -07:00
statfs.c
super.c for-5.8/block-2020-06-01 2020-06-02 15:29:19 -07:00
sync.c vfs: track per-sb writeback errors and report them to syncfs 2020-06-02 10:59:05 -07:00
timerfd.c
userfaultfd.c userfaultfd: wp: declare _UFFDIO_WRITEPROTECT conditionally 2020-04-07 10:43:40 -07:00
utimes.c utimensat: AT_EMPTY_PATH support 2020-05-14 16:44:24 +02:00
xattr.c xattr: fix uninitialized out-param 2020-04-09 15:33:09 -04:00