[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211012090755.177441-1-guangming.cao@mediatek.com>
Date: Tue, 12 Oct 2021 17:07:55 +0800
From: <guangming.cao@...iatek.com>
To: <christian.koenig@....com>
CC: <dri-devel@...ts.freedesktop.org>, <guangming.cao@...iatek.com>,
<linaro-mm-sig@...ts.linaro.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <linux-media@...r.kernel.org>,
<linux-mediatek@...ts.infradead.org>, <matthias.bgg@...il.com>,
<sumit.semwal@...aro.org>, <wsd_upstream@...iatek.com>,
Guangming Cao <Guangming.Cao@...iatek.com>
Subject: Re: [PATCH v2] dma-buf: acquire name lock before read/write dma_buf.name
From: Guangming Cao <Guangming.Cao@...iatek.com>
> Am 08.10.21 um 09:54 schrieb guangming.cao@...iatek.com:
> > From: Guangming Cao <Guangming.Cao@...iatek.com>
> >
> > 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@...iatek.com>
>
> Reviewed-by: Christian König <christian.koenig@....com>
>
> Going to push that upstream if nobody else objects.
>
> Thanks,
> Christian.
I'm sorry to disturb you, actually I need this patch to solve our issues.
Is there any question about it? seems it hasn't been merged into mainline.
Thanks,
Guangming.
>
> > ---
> > drivers/dma-buf/dma-buf.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> > index 511fe0d217a0..a7f6fd13a635 100644
> > --- a/drivers/dma-buf/dma-buf.c
> > +++ b/drivers/dma-buf/dma-buf.c
> > @@ -1372,6 +1372,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,
> > @@ -1379,6 +1381,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);
Powered by blists - more mailing lists