android_kernel_oneplus_msm8998/fs/fuse
Ritesh Harjani ba869c9422 ANDROID: fuse: Add null terminator to path in canonical path to avoid issue
page allocated in fuse_dentry_canonical_path to be handled in
fuse_dev_do_write is allocated using __get_free_pages(GFP_KERNEL).
This may not return a page with data filled with 0. Now this
page may not have a null terminator at all.
If this happens and userspace fuse daemon screws up by passing a string
to kernel which is not NULL terminated (or did not fill anything),
then inside fuse driver in kernel when we try to do
strlen(fuse_dev_write->kern_path->getname_kernel)
on that page data -> it may give us issue with kernel paging request.

Unable to handle kernel paging request at virtual address
------------[ cut here ]------------
<..>
PC is at strlen+0x10/0x90
LR is at getname_kernel+0x2c/0xf4
<..>
strlen+0x10/0x90
kern_path+0x28/0x4c
fuse_dev_do_write+0x5b8/0x694
fuse_dev_write+0x74/0x94
do_iter_readv_writev+0x80/0xb8
do_readv_writev+0xec/0x1cc
vfs_writev+0x54/0x64
SyS_writev+0x64/0xe4
el0_svc_naked+0x24/0x28

To avoid this we should ensure in case of FUSE_CANONICAL_PATH,
the page is null terminated.

Change-Id: I33ca7cc76b4472eaa982c67bb20685df451121f5
Bug: 75984715
[Daniel - small edit, using args size ]
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Git-Repo: https://source.codeaurora.org/quic/la/kernel/msm-4.9/commit/?h=aosp-new/android-4.9&id=4fb542f2aa1414cea5686efcf72a411b7213c375
Git-Commit: 4fb542f2aa1414cea5686efcf72a411b7213c375
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
2018-04-09 00:57:41 -07:00
..
control.c VFS: normal filesystems (and lustre): d_inode() annotations 2015-04-15 15:06:57 -04:00
cuse.c fuse: Add reference counting for fuse_io_priv 2016-04-12 09:08:58 -07:00
dev.c ANDROID: fuse: Add null terminator to path in canonical path to avoid issue 2018-04-09 00:57:41 -07:00
dir.c Merge android-4.4.96 (aed4c54) into msm-4.4 2017-12-12 14:25:27 -08:00
file.c Merge android-4.4@610af85 (v4.4.85) into msm-4.4 2017-09-04 17:20:09 -07:00
fuse_i.h Merge remote-tracking branch 'msm4.4/tmp-da9a92f' into msm-4.4 2016-10-28 10:48:35 -07:00
fuse_passthrough.h fuse: Add support for passthrough read/write 2016-03-22 11:15:47 -07:00
inode.c Merge branch 'v4.4-16.09-android-tmp' into lsk-v4.4-16.09-android 2016-12-16 13:52:17 -08:00
Kconfig fuse: Move CUSE Kconfig entry from fs/Kconfig into fs/fuse/Kconfig 2013-01-17 13:08:45 +01:00
Makefile fuse: Add support for passthrough read/write 2016-03-22 11:15:47 -07:00
passthrough.c fuse: Grab the fc->lock for inode updates in passthrough 2016-09-20 13:52:51 -07:00