All of lore.kernel.org
 help / color / mirror / Atom feed
From: cuigaosheng <cuigaosheng1@huawei.com>
To: "Charan Teja Kalla" <quic_charante@quicinc.com>,
	"Christian König" <christian.koenig@amd.com>,
	"T.J. Mercier" <tjmercier@google.com>
Cc: <sumit.semwal@linaro.org>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Pavan Kondeti <quic_pkondeti@quicinc.com>,
	<linux-media@vger.kernel.org>, <dri-devel@lists.freedesktop.org>,
	<linaro-mm-sig@lists.linaro.org>
Subject: Re: [PATCH] dma-buf: Fix possible UAF in dma_buf_export
Date: Thu, 24 Nov 2022 19:31:14 +0800	[thread overview]
Message-ID: <ef22322b-0134-3d63-f7c5-97f240ae7fd8@huawei.com> (raw)
In-Reply-To: <e12784da-b3e3-ddec-0e84-f968d60097c4@quicinc.com>

Thanks T.J and Christian, thanks everyone for taking time to review this patch.

Charan, actually I don't have a good patch to to fix it, if you can submit
a new patch to solve it, please feel free to do it.

By the way, I'd appreciate it if you could send to me the new patch when you submit it.

Thanks again!

Gaosheng.

On 2022/11/24 13:56, Charan Teja Kalla wrote:
> Thanks T.J and Christian for the inputs.
>
> On 11/19/2022 7:00 PM, Christian König wrote:
>>>      Yes, exactly that's the idea.
>>>
>>>      The only alternatives I can see would be to either move allocating
>>>      the
>>>      file and so completing the dma_buf initialization last again or just
>>>      ignore errors from sysfs.
>>>
>>>      > If we still want to avoid calling dmabuf->ops->release(dmabuf) in
>>>      > dma_buf_release like the comment says I guess we could use
>>>      sysfs_entry
>>>      > and ERR_PTR to flag that, otherwise it looks like we'd need a bit
>>>      > somewhere.
>>>
>>>      No, this should be dropped as far as I can see. The sysfs cleanup
>>>      code
>>>      looks like it can handle not initialized kobj pointers.
>>>
>>>
>>> Yeah there is also the null check in dma_buf_stats_teardown() that
>>> would prevent it from running, but I understood the comment to be
>>> referring to the release() dma_buf_ops call into the exporter which
>>> comes right after the teardown call. That looks like it's preventing
>>> the fput task work calling back into the exporter after the exporter
>>> already got an error from dma_buf_export(). Otherwise the exporter
>>> sees a release() for a buffer that it doesn't know about / thinks
>>> shouldn't exist. So I could imagine an exporter trying to double free:
>>> once for the failed dma_buf_export() call, and again when the
>>> release() op is called later.
>>
>> Oh, very good point as well. Yeah, then creating the file should
>> probably come last.
>>
> @Gaosheng: Could you please make these changes or you let me to do?
>
>> Regards,
>> Christian.
> .

WARNING: multiple messages have this Message-ID (diff)
From: cuigaosheng <cuigaosheng1@huawei.com>
To: "Charan Teja Kalla" <quic_charante@quicinc.com>,
	"Christian König" <christian.koenig@amd.com>,
	"T.J. Mercier" <tjmercier@google.com>
Cc: Pavan Kondeti <quic_pkondeti@quicinc.com>,
	dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org,
	sumit.semwal@linaro.org, Dan Carpenter <dan.carpenter@oracle.com>,
	linux-media@vger.kernel.org
Subject: Re: [PATCH] dma-buf: Fix possible UAF in dma_buf_export
Date: Thu, 24 Nov 2022 19:31:14 +0800	[thread overview]
Message-ID: <ef22322b-0134-3d63-f7c5-97f240ae7fd8@huawei.com> (raw)
In-Reply-To: <e12784da-b3e3-ddec-0e84-f968d60097c4@quicinc.com>

Thanks T.J and Christian, thanks everyone for taking time to review this patch.

Charan, actually I don't have a good patch to to fix it, if you can submit
a new patch to solve it, please feel free to do it.

By the way, I'd appreciate it if you could send to me the new patch when you submit it.

Thanks again!

Gaosheng.

On 2022/11/24 13:56, Charan Teja Kalla wrote:
> Thanks T.J and Christian for the inputs.
>
> On 11/19/2022 7:00 PM, Christian König wrote:
>>>      Yes, exactly that's the idea.
>>>
>>>      The only alternatives I can see would be to either move allocating
>>>      the
>>>      file and so completing the dma_buf initialization last again or just
>>>      ignore errors from sysfs.
>>>
>>>      > If we still want to avoid calling dmabuf->ops->release(dmabuf) in
>>>      > dma_buf_release like the comment says I guess we could use
>>>      sysfs_entry
>>>      > and ERR_PTR to flag that, otherwise it looks like we'd need a bit
>>>      > somewhere.
>>>
>>>      No, this should be dropped as far as I can see. The sysfs cleanup
>>>      code
>>>      looks like it can handle not initialized kobj pointers.
>>>
>>>
>>> Yeah there is also the null check in dma_buf_stats_teardown() that
>>> would prevent it from running, but I understood the comment to be
>>> referring to the release() dma_buf_ops call into the exporter which
>>> comes right after the teardown call. That looks like it's preventing
>>> the fput task work calling back into the exporter after the exporter
>>> already got an error from dma_buf_export(). Otherwise the exporter
>>> sees a release() for a buffer that it doesn't know about / thinks
>>> shouldn't exist. So I could imagine an exporter trying to double free:
>>> once for the failed dma_buf_export() call, and again when the
>>> release() op is called later.
>>
>> Oh, very good point as well. Yeah, then creating the file should
>> probably come last.
>>
> @Gaosheng: Could you please make these changes or you let me to do?
>
>> Regards,
>> Christian.
> .

  reply	other threads:[~2022-11-24 11:31 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17  6:21 [PATCH] dma-buf: Fix possible UAF in dma_buf_export Gaosheng Cui
2022-11-17  6:21 ` Gaosheng Cui
2022-11-17  7:48 ` Charan Teja Kalla
2022-11-17  7:48   ` Charan Teja Kalla
2022-11-17 10:16   ` Christian König
2022-11-17 10:16     ` Christian König
2022-11-18  2:36     ` T.J. Mercier
2022-11-18  2:36       ` T.J. Mercier
2022-11-18  8:27       ` Christian König
2022-11-18  8:27         ` Christian König
2022-11-18 17:05         ` T.J. Mercier
2022-11-19 13:30           ` Christian König
2022-11-24  5:56             ` Charan Teja Kalla
2022-11-24  5:56               ` Charan Teja Kalla
2022-11-24 11:31               ` cuigaosheng [this message]
2022-11-24 11:31                 ` cuigaosheng
2022-11-24 12:05               ` cuigaosheng
2022-11-24 12:05                 ` cuigaosheng
2022-11-24 12:37                 ` Christian König
2022-11-24 12:37                   ` Christian König
2022-11-24 12:49                   ` cuigaosheng
2022-11-24 12:49                     ` cuigaosheng
2022-11-24 12:55                     ` [Linaro-mm-sig] " Christian König
2022-11-24 12:55                       ` Christian König
2022-12-06 12:55                       ` Charan Teja Kalla
2022-12-06 12:55                         ` Charan Teja Kalla
2022-12-06 13:08                         ` Christian König
2022-12-06 13:08                           ` Christian König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ef22322b-0134-3d63-f7c5-97f240ae7fd8@huawei.com \
    --to=cuigaosheng1@huawei.com \
    --cc=christian.koenig@amd.com \
    --cc=dan.carpenter@oracle.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-media@vger.kernel.org \
    --cc=quic_charante@quicinc.com \
    --cc=quic_pkondeti@quicinc.com \
    --cc=sumit.semwal@linaro.org \
    --cc=tjmercier@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.