android_kernel_google_msm/fs
Jan Kara 44882b1b6f lib/radix-tree.c: make radix_tree_node_alloc() work correctly within interrupt
With users of radix_tree_preload() run from interrupt (block/blk-ioc.c is
one such possible user), the following race can happen:

radix_tree_preload()
...
radix_tree_insert()
  radix_tree_node_alloc()
    if (rtp->nr) {
      ret = rtp->nodes[rtp->nr - 1];
<interrupt>
...
radix_tree_preload()
...
radix_tree_insert()
  radix_tree_node_alloc()
    if (rtp->nr) {
      ret = rtp->nodes[rtp->nr - 1];

And we give out one radix tree node twice.  That clearly results in radix
tree corruption with different results (usually OOPS) depending on which
two users of radix tree race.

We fix the problem by making radix_tree_node_alloc() always allocate fresh
radix tree nodes when in interrupt.  Using preloading when in interrupt
doesn't make sense since all the allocations have to be atomic anyway and
we cannot steal nodes from process-context users because some users rely
on radix_tree_insert() succeeding after radix_tree_preload().
in_interrupt() check is somewhat ugly but we cannot simply key off passed
gfp_mask as that is acquired from root_gfp_mask() and thus the same for
all preload users.

Another part of the fix is to avoid node preallocation in
radix_tree_preload() when passed gfp_mask doesn't allow waiting.  Again,
preallocation in such case doesn't make sense and when preallocation would
happen in interrupt we could possibly leak some allocated nodes.  However,
some users of radix_tree_preload() require following radix_tree_insert()
to succeed.  To avoid unexpected effects for these users,
radix_tree_preload() only warns if passed gfp mask doesn't allow waiting
and we provide a new function radix_tree_maybe_preload() for those users
which get different gfp mask from different call sites and which are
prepared to handle radix_tree_insert() failure.

Change-Id: Iab513ed95e8a98cd890e68a820181a8a915da9aa
Signed-off-by: Jan Kara <jack@suse.cz>
Cc: Jens Axboe <jaxboe@fusionio.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-12-07 21:02:05 +03:00
..
9p mm: kill vma flag VM_CAN_NONLINEAR 2020-11-29 16:11:40 +03:00
adfs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
affs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
afs don't pass nameidata to ->create() 2018-12-07 22:28:00 +04:00
autofs4 stop passing nameidata to ->lookup() 2018-12-07 22:26:28 +04:00
befs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
bfs don't pass nameidata to ->create() 2018-12-07 22:28:00 +04:00
btrfs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
cachefiles don't pass nameidata * to vfs_create() 2018-12-07 22:28:48 +04:00
ceph mm: kill vma flag VM_CAN_NONLINEAR 2020-11-29 16:11:40 +03:00
cifs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
coda fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
configfs stop passing nameidata to ->lookup() 2018-12-07 22:26:28 +04:00
cramfs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
crypto
debugfs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
devpts fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
dlm
ecryptfs don't pass nameidata * to vfs_create() 2018-12-07 22:28:48 +04:00
efs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
exofs don't pass nameidata to ->create() 2018-12-07 22:28:00 +04:00
exportfs
ext2 fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
ext3 fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
ext4 fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
f2fs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
fat fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
freevxfs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
fscache lib/radix-tree.c: make radix_tree_node_alloc() work correctly within interrupt 2020-12-07 21:02:05 +03:00
fuse fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
gfs2 fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
hfs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
hfsplus fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
hostfs don't pass nameidata to ->create() 2018-12-07 22:28:00 +04:00
hpfs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
hppfs stop passing nameidata to ->lookup() 2018-12-07 22:26:28 +04:00
hugetlbfs don't pass nameidata to ->create() 2018-12-07 22:28:00 +04:00
isofs stop passing nameidata to ->lookup() 2018-12-07 22:26:28 +04:00
jbd
jbd2
jffs2 fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
jfs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
lockd
logfs don't pass nameidata to ->create() 2018-12-07 22:28:00 +04:00
minix fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
ncpfs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
nfs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
nfs_common
nfsd don't pass nameidata * to vfs_create() 2018-12-07 22:28:48 +04:00
nilfs2 fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
nls
notify fanotify: check file flags passed in fanotify_init 2018-12-07 22:28:48 +04:00
ntfs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
ocfs2 fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
omfs don't pass nameidata to ->create() 2018-12-07 22:28:00 +04:00
openpromfs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
proc fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
pstore fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
qnx4 fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
qnx6 fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
quota vfs: define struct filename and have getname() return it 2018-12-07 22:28:48 +04:00
ramfs don't pass nameidata to ->create() 2018-12-07 22:28:00 +04:00
reiserfs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
romfs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
sdcardfs mm: kill vma flag VM_CAN_NONLINEAR 2020-11-29 16:11:40 +03:00
squashfs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
sysfs stop passing nameidata to ->lookup() 2018-12-07 22:26:28 +04:00
sysv fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
ubifs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
udf fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
ufs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
xfs fs: push sync_filesystem() down to the file system's remount_fs() 2020-11-29 16:11:45 +03:00
yaffs2
aio.c Merge remote-tracking branch 'stable/linux-3.4.y' into lineage-15.1 2017-12-27 17:13:15 +03:00
anon_inodes.c
attr.c Merge remote-tracking branch 'stable/linux-3.4.y' into lineage-15.1 2017-12-27 17:13:15 +03:00
bad_inode.c mm/fs: remove truncate_range 2020-12-07 20:57:30 +03:00
binfmt_aout.c
binfmt_elf.c
binfmt_elf_fdpic.c
binfmt_em86.c
binfmt_flat.c
binfmt_misc.c Merge remote-tracking branch 'stable/linux-3.4.y' into lineage-15.1 2017-12-27 17:13:15 +03:00
binfmt_script.c
binfmt_som.c
bio-integrity.c
bio.c
block_dev.c
buffer.c Merge remote-tracking branch 'stable/linux-3.4.y' into lineage-15.1 2017-12-27 17:13:15 +03:00
char_dev.c
compat.c vfs: define struct filename and have getname() return it 2018-12-07 22:28:48 +04:00
compat_binfmt_elf.c
compat_ioctl.c Merge remote-tracking branch 'stable/linux-3.4.y' into lineage-15.1 2017-12-27 17:13:15 +03:00
dcache.c [O_TMPFILE] it's still short a few helpers, but infrastructure should be OK now... 2018-12-07 22:28:48 +04:00
dcookies.c
direct-io.c
drop_caches.c
eventfd.c
eventpoll.c Merge remote-tracking branch 'stable/linux-3.4.y' into lineage-15.1 2017-12-27 17:13:15 +03:00
exec.c vfs: make path_openat take a struct filename pointer 2018-12-07 22:28:48 +04:00
fcntl.c vfs: add missing check for __O_TMPFILE in fcntl_init() 2018-12-07 22:28:48 +04:00
fhandle.c
fifo.c
file.c
file_table.c
filesystems.c vfs: define struct filename and have getname() return it 2018-12-07 22:28:48 +04:00
fs-writeback.c Merge remote-tracking branch 'stable/linux-3.4.y' into lineage-15.1 2017-12-27 17:13:15 +03:00
fs_struct.c
generic_acl.c
inode.c allow the temp files created by open() to be linked to 2018-12-07 22:28:48 +04:00
internal.h vfs: make path_openat take a struct filename pointer 2018-12-07 22:28:48 +04:00
ioctl.c
ioprio.c Merge remote-tracking branch 'stable/linux-3.4.y' into lineage-15.1 2017-12-27 17:13:15 +03:00
Kconfig
Kconfig.binfmt
libfs.c stop passing nameidata to ->lookup() 2018-12-07 22:26:28 +04:00
locks.c
Makefile
mbcache.c
mount.h
mpage.c
namei.c path_openat(): fix double fput() 2018-12-07 22:28:48 +04:00
namespace.c vfs: define struct filename and have getname() return it 2018-12-07 22:28:48 +04:00
no-block.c
open.c fs: Fix file mode for O_TMPFILE 2018-12-07 22:28:48 +04:00
pipe.c Merge remote-tracking branch 'stable/linux-3.4.y' into lineage-15.1 2017-12-27 17:13:15 +03:00
pnode.c Merge remote-tracking branch 'stable/linux-3.4.y' into lineage-15.1 2017-12-27 17:13:15 +03:00
pnode.h
posix_acl.c Merge remote-tracking branch 'stable/linux-3.4.y' into lineage-15.1 2017-12-27 17:13:15 +03:00
proc_namespace.c
read_write.c
read_write.h
readdir.c
select.c Merge remote-tracking branch 'stable/linux-3.4.y' into lineage-15.1 2017-12-27 17:13:15 +03:00
seq_file.c
signalfd.c
splice.c Merge remote-tracking branch 'stable/linux-3.4.y' into lineage-15.1 2017-12-27 17:13:15 +03:00
stack.c
stat.c vfs: make O_PATH file descriptors usable for 'fstat()' 2020-11-22 01:21:34 +03:00
statfs.c
super.c vmscan: remove obsolete shrink_control comment 2020-11-29 16:11:26 +03:00
sync.c fs/sync.c: make sync_file_range(2) use WB_SYNC_NONE writeback 2017-12-31 13:02:49 +03:00
timerfd.c
utimes.c
xattr.c xattr: extract simple_xattr code from tmpfs 2020-12-07 21:01:31 +03:00
xattr_acl.c