android_kernel_motorola_sm6375/drivers/dma-buf
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Liam Mark 0838b6c739 dma-buf: Handle dentry->d_fsdata being NULL
Since the dma_buf_dentry_ops ops are set on the dma-buf dentry, in
alloc_file_pseudo, and this is before the dma-buf is assigned to
dentry->d_fsdata, in dma_buf_getfile, it is possible for the
dma_buf_dentry_ops functions to be called with dentry->d_fsdata == NULL.

For example:

BUG: KASAN: null-ptr-deref in dma_buf_release+0x2c/0x254 drivers/dma-buf/dma-buf.c:88
Call trace:
dump_backtrace+0x0/0x2c8 arch/arm64/kernel/time.c:50
show_stack+0x20/0x2c arch/arm64/kernel/traps.c:140
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x154/0x1f4 lib/dump_stack.c:118
__kasan_report+0x1ac/0x218 mm/kasan/report.c:510
kasan_report+0x10/0x18 mm/kasan/common.c:634
check_memory_region_inline mm/kasan/generic.c:181 [inline]
__asan_load4+0x90/0x98 mm/kasan/generic.c:250
dma_buf_release+0x2c/0x254 drivers/dma-buf/dma-buf.c:88
__dentry_kill+0x294/0x31c fs/dcache.c:584
dentry_kill fs/dcache.c:673 [inline]
dput+0x250/0x380 fs/dcache.c:859
path_put+0x24/0x40 fs/namei.c:485
alloc_file_pseudo+0x1a4/0x200 fs/file_table.c:235
dma_buf_getfile drivers/dma-buf/dma-buf.c:473 [inline]
dma_buf_export+0x25c/0x3ec drivers/dma-buf/dma-buf.c:585
ion_dmabuf_alloc+0x168/0x1d4 drivers/staging/android/ion/ion_dma_buf.c:394
ion_alloc_fd drivers/staging/android/ion/ion.c:54 [inline]
ion_ioctl+0x24c/0x5c8 drivers/staging/android/ion/ion.c:194
vfs_ioctl fs/ioctl.c:47 [inline]
do_vfs_ioctl+0x55c/0xcb4 fs/ioctl.c:699
ksys_ioctl fs/ioctl.c:714 [inline]
__do_sys_ioctl fs/ioctl.c:721 [inline]
__se_sys_ioctl fs/ioctl.c:719 [inline]
__arm64_sys_ioctl+0xa0/0xe4 fs/ioctl.c:719
__invoke_syscall arch/arm64/kernel/syscall.c:36 [inline]
invoke_syscall arch/arm64/kernel/syscall.c:48 [inline]
el0_svc_common+0x130/0x294 arch/arm64/kernel/syscall.c:117
el0_svc_handler+0xdc/0xec arch/arm64/kernel/syscall.c:163
el0_svc+0x8/0xc arch/arm64/kernel/entry.S:1031

Ideally we would change the dma-buf code to ensure that the
dma_buf_dentry_ops ops are set on the dma-buf dentry after the dentry's
d_fsdata has been set, however there does not appear to be a clean way to
do this.
For example if the dma_buf_fs_type was changed so that it's dops weren't
configured the alloc_file_pseudo function would still assign the anon_ops
to the dma-buf dentry, and if we then tried to configure the dma-buf
dentry's dentry_operations later on, using d_set_d_op, the function would
WARN since the dma-buf's dentry already has its dentry_operations
configured.

So instead change the dma_buf_dentry_ops functions to handle the case
where the dma-buf dentry's d_fsdata may be NULL.

Change-Id: Idb1ef749c623b17fb8b7ce90f0c472a5ba298297
Signed-off-by: Liam Mark <lmark@codeaurora.org>
2020-09-21 09:20:34 -07:00
..
dma-buf-ref.c dma-buf: Export missing dma_buf_ref_mod symbol 2020-01-15 09:01:12 -07:00
dma-buf.c dma-buf: Handle dentry->d_fsdata being NULL 2020-09-21 09:20:34 -07:00
dma-fence-array.c dma-fence: Propagate errors to dma-fence-array container 2019-08-12 08:25:52 +01:00
dma-fence-chain.c dma-buf: fix stack corruption in dma_fence_chain_release 2019-08-05 17:32:33 +02:00
dma-fence.c dma-fence: Store the timestamp in the same union as the cb_list 2019-08-17 18:46:33 +01:00
dma-resv.c dma-buf/resv: fix exclusive fence get 2019-10-10 17:05:20 +02:00
Kconfig dma-buf: Add support to set a destructor on a dma-buf 2020-08-01 22:57:06 -07:00
Makefile Merge remote-tracking branch 'remotes/origin/tmp-935f8bc6f7aa' into msm-lahaina 2019-10-10 20:02:38 -07:00
selftest.c dma-buf: Introduce selftesting framework 2019-08-19 18:01:34 +01:00
selftest.h dma-buf: Introduce selftesting framework 2019-08-19 18:01:34 +01:00
selftests.h dma-buf: Add selftests for dma-fence 2019-08-19 18:09:46 +01:00
seqno-fence.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174 2019-05-30 11:26:41 -07:00
st-dma-fence.c dmabuf: Mark up onstack timer for selftests 2019-08-20 13:49:15 +01:00
sw_sync.c dma-buf/sw_sync: Synchronize signal vs syncpt free 2019-08-13 07:57:51 +01:00
sync_debug.c Linux 5.2-rc5 2019-06-19 12:07:29 +02:00
sync_debug.h
sync_file.c dma-buf: Fix memory leak in sync_file_merge() 2019-12-21 11:04:48 +01:00
sync_trace.h
udmabuf.c udmabuf: actually unmap the scatterlist 2019-06-05 10:41:17 +02:00