diff options
author | Guangming Cao <Guangming.Cao@mediatek.com> | 2021-10-08 10:54:20 +0300 |
---|---|---|
committer | Christian König <christian.koenig@amd.com> | 2021-10-29 10:19:31 +0300 |
commit | 8c0fd126263730c35927cc8445727afb79219a19 (patch) | |
tree | 2ddb83dec10a44a474cd9640ce4c022c53262b59 /drivers/dma-buf/dma-buf.c | |
parent | 61b1d445f3bfe4c3ba4335ceeb7e8ba688fd31e2 (diff) | |
download | linux-8c0fd126263730c35927cc8445727afb79219a19.tar.xz |
dma-buf: acquire name lock before read/write dma_buf.name
Because dma-buf.name can be freed in func: "dma_buf_set_name",
so, we need to acquire lock first before we read/write dma_buf.name
to prevent Use After Free(UAF) issue.
Signed-off-by: Guangming Cao <Guangming.Cao@mediatek.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211008075420.42874-1-guangming.cao@mediatek.com
Diffstat (limited to 'drivers/dma-buf/dma-buf.c')
-rw-r--r-- | drivers/dma-buf/dma-buf.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 63d32261b63f..92492e314bd9 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -1389,6 +1389,8 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused) if (ret) goto error_unlock; + + spin_lock(&buf_obj->name_lock); seq_printf(s, "%08zu\t%08x\t%08x\t%08ld\t%s\t%08lu\t%s\n", buf_obj->size, buf_obj->file->f_flags, buf_obj->file->f_mode, @@ -1396,6 +1398,7 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused) buf_obj->exp_name, file_inode(buf_obj->file)->i_ino, buf_obj->name ?: ""); + spin_unlock(&buf_obj->name_lock); robj = buf_obj->resv; fence = dma_resv_excl_fence(robj); |