1
0
Fork 0
alistair23-linux/drivers/dma-buf
Charan Teja Reddy 198d9f7e90 dmabuf: fix NULL pointer dereference in dma_buf_release()
commit 19a508bd1a upstream.

NULL pointer dereference is observed while exporting the dmabuf but
failed to allocate the 'struct file' which results into the dropping of
the allocated dentry corresponding to this file in the dmabuf fs, which
is ending up in dma_buf_release() and accessing the uninitialzed
dentry->d_fsdata.

Call stack on 5.4 is below:
 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

Fix this by checking for the valid pointer in the dentry->d_fsdata.

Fixes: 4ab59c3c63 ("dma-buf: Move dma_buf_release() from fops to dentry_ops")
Cc: <stable@vger.kernel.org> [5.7+]
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/391319/
Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-10-01 13:18:24 +02:00
..
Kconfig dma-buf: Introduce selftesting framework 2019-08-19 18:01:34 +01:00
Makefile dma-buf: Add selftests for dma-fence 2019-08-19 18:09:46 +01:00
dma-buf.c dmabuf: fix NULL pointer dereference in dma_buf_release() 2020-10-01 13:18:24 +02: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: Serialise signal enabling (dma_fence_enable_sw_signaling) 2020-10-01 13:17:11 +02:00
dma-resv.c dma-buf/resv: fix exclusive fence get 2019-10-10 17:05:20 +02: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 dma-buf: Remove unused sync_dump() 2019-04-23 09:30:07 +01:00
sync_file.c dma-buf: Fix memory leak in sync_file_merge() 2019-12-21 11:04:48 +01:00
sync_trace.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
udmabuf.c udmabuf: actually unmap the scatterlist 2019-06-05 10:41:17 +02:00